Render ArrowJS templates and partials to string.
Works wherever JS does.
npm install arrow-render-to-string
import { html } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'
const message = 'Hello World'
const view = html`<p>${message}</p>`
renderToString(view) //=> <p>Hello World</p>
import { html, reactive } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'
const state = reactive({
count: 0,
})
const view = html`<p>${() => state.count}</p>`
renderToString(view) //=> <p>0</p>
Events are stripped out, for you to re-hydrate on the client
import { html, reactive } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'
const state = reactive({
count: 0,
})
const view = html`<button @click="${() => (state.count += 1)}">
${() => state.count}
</button>`
renderToString(view) //=> <button @click="<!--➳❍-->">0</button>