Mithril with JSX
HTML
<script src="//lhorie.github.io/mithril/mithril.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<div id="app"></div>
Babel + JSX
/** @jsx m */
const Hello = {
handleClick(e){
e.target.style.color = 'green'
},
view(ctrl, props, children){
return (
<div>
<h1 onclick={this.handleClick}>
{props.greeting}
</h1>
{children}
</div>
)
}
}
const Hello2 = {
handleClick(e){
e.target.style.color = 'green'
},
view(ctrl, props, children){
return (
<div>
<h4 onclick={this.handleClick}>
subtitle
</h4>
{children}
</div>
)
}greeting="Hello World"
}
m.mount(
document.getElementById("app"),
<Hello greeting="Hello World">
<Hello2></Hello2>
</Hello>
)