kweb-core
kweb-core copied to clipboard
DSL revamp
I think we need to rethink the DSL to support this kind of usage:
doc.body {
section {
classes("section")
h1 {
classes("title")
text("What would you like to know?")
}
val textArea = textArea {
classes("textarea")
attr(
"placeholder" to "Ask a question",
"rows" to 10
)
}
button {
classes("button", "is-primary")
text("Submit")
parent.on(retrieveJs = textArea.valueJsExpression).click {
val value = it.retrieved.jsonPrimitive.content
}
}
}
}
The most notable architectural change will be merging the functionality of ElementCreator into Element.
Wouldn't it make sense to leverage https://github.com/Kotlin/kotlinx.html here?
It's a good question, but I don't think so because kotlinx isn't solving quite the same problem as kweb, which is doing more than just HTML generation.
Specifically, Kweb's render {} and KVar mechanisms are fairly fundamental and I don't think they would play nice with Kotlinx, also stuff like JavaScript event listeners.
That being said, I think kotlinx can provide useful inspiration for the DSL design.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This is on the to-do list.