October 2019
Intermediate to advanced
434 pages
11h 54m
English
The official Kotlin documentation includes an example of a DSL for working with HTML. The example includes a playground to work with the DSL to see how the different functions work.
The following code snippet demonstrates the usage of this Kotlin DSL to declare valid HTML code via Kotlin syntax:
fun main() { val result = html { head { title { +"HTML encoding with Kotlin" } } body { h1 { +"HTML encoding with Kotlin" } p { +"this format can be used as an" +"alternative markup to HTML" } // an element with attributes and text content a(href = "http://jetbrains.com/kotlin") { +"Kotlin" } // mixed content ...
Read now
Unlock full access