arrow-render-to-string
v0.0.3
Published
<p> <img width="1191" alt="Frame 13" src="https://github.com/dumbjs/arrow-render-to-string/assets/43572006/3a8910fb-4a23-49cc-8407-f8c296275ba7"> </p>
Downloads
3
Readme
Render ArrowJS templates and partials to string.
Works wherever JS does.
Installation
npm install arrow-render-to-string
Usage/Examples
Basic
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>
Reactive Variables
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
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>