Closed michaelsboost closed 1 month ago
Should be as simple as const html = htm.bind(m);
.
An integration with Mithril would look almost identical to their React integration:
import m from 'mithril'
import htm from 'htm'
export const html = htm.bind(m)
Thanks got it to work
import htm from 'https://unpkg.com/htm?module'
const html = htm.bind(m)
const app = () => {
let count = 0
return {
view: () => html`
<div class="flex flex-col items-center justify-center absolute inset-0">
<h1 class="text-3xl font-thin mb-4">👋 Hello, Mithril! 🌎</h1>
<p class="text-xl mb-4">Counter: <span class="font-mono">${count}</span></p>
<button onclick=${() => count++}>+</button>
</div>`
}
}
m.mount(document.getElementById('root'), app)
I know I can use htm with Hyperapp like this...
I know I can use htm with Preact like this...
I can go on with various examples. Can I do the same with Mithril.js?