3 ms·
Ah, that's unfortunate. At least with React (and Mithril) you can use it from pure JavaScript, which lets you replace JSX with Kotlin's DSL[1] for HTML. [1] ht
by ptx 6y ago
Ah, that's unfortunate. At least with React (and Mithril) you can use it from pure JavaScript, which lets you replace JSX with Kotlin's DSL[1] for HTML.
[1] https://github.com/Kotlin/kotlinx.html/blob/master/README.md https://github.com/Kotlin/kotlinx.html/blob/master/README.md
- yencabulator 6y agoI find using HTML for HTML much more pleasant.
- ptx 6y agoI do too, for simple things. But what do you do when you have repeating patterns and want to eliminate duplication? Usually a template language would be introduced, and now it's not HTML anymore; tools that work on plain HTML don't work with the special template language; commenting out code gets tricky because the same file has multiple kinds of syntax intermixed. And in addition to your HTML and your template language you still have your programming language. Kotlin solves this by using the programming language for the whole thing, allowing you to extract repeating parts using plain functions as you would with any other code. Of course it's not as well suited as HTML itself for writing HTML, but it might be better than HTML + some template language + some programming language. Another way to go, to avoid having a mysterious mixture of almost-HTML embedded within some other syntax, is to do what Thymeleaf does[1] and have the template language be embedded inside HTML (rather than the other way around) so that the template file is actually valid HTML. [1] https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#support-for-html5-friendly-attribute-and-element-names https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.h...