Kotlinx.html and Mithril


I’m looking at doing a wrapper for mithril (https://mithril.js.org) in kotlin. It’s very minimalist, but it is powerful. I can figure out how to do most of the functions, but I love the design of kotlinx.html, and it could be a powerful way to template if I can figure out how to combine the two.

An example of how to do templating in mithril is:

let text = "foo"
m(“div.some-class”, {attributes: “go here”, [
m(“h1”, {classes: “can-also-go-here”}, text)
m(“h3”, “attributes can be omitted as well”)

I wonder if someone knows of a good way to get kotlinx.html to generate mithril view nodes, or can point me to the right place in the project. I’ve looked around, my guess is that it has to do with creating my own implementation of HTMLTag, but I’m not sure.



In case anyone is interested and sees this, I think I might have a possible solution. React in Kotlin seems to have a similar issue, the code here might help me: https://github.com/Kotlin/kotlin-fullstack-sample/tree/master/frontend/src/org/jetbrains/react/dom