Skip to content

Simplify HTML DSL

Pre-release
Pre-release
Compare
Choose a tag to compare
@sanity sanity released this 08 Dec 18:16
· 1345 commits to master since this release

With this release we have redesigned and simplified our HTML DSL so that:

    // Old DSL style
    Kweb(port = 1234) {
        doc.body.new {
            ul().new {
                li().text("One")
                li().text("Two")
                li().text("Three")
            }
        }
    }

Becomes:

    // New DSL style
    Kweb(port = 1234) {
        doc.body {
            ul {
                li().text("One")
                li().text("Two")
                li().text("Three")
            }
        }
    }

Note that elements and their children can now be created without the new {} function - although it is still available for when you need to add children to a pre-existing Element, so existing code shouldn't require significant changes.

Please take a look at our user manual to learn more about Kweb.