Hey how can i use html content like:
<meta property="og:locale" content="en"/>
with the Kotlin HTML Type Safe builder? I cannot find something like the property variable in the meta function
Hey how can i use html content like:
<meta property="og:locale" content="en"/>
with the Kotlin HTML Type Safe builder? I cannot find something like the property variable in the meta function
A typesafe extension to the answer of @Михаил Нафталь, in case you need to use a lot of those tags, is this:
fun HEAD.metaProperty(propertyName: String, content: String) = meta(content = content) {
attributes["property"] = propertyName
}
Then you can use it like this:
val htmlCode = buildString {
appendHTML().html {
head {
metaProperty("og:locale", "en")
}
body {
h1 { +"Hello" }
}
}
}
println(htmlCode)