An open API service indexing awesome lists of open source software.

https://github.com/dumbjs/arrow-render-to-string

Render ArrowJS templates and partials to string. (Deno, Node, Bun, Browser)
https://github.com/dumbjs/arrow-render-to-string

arrow-js arrowjs browser bun deno node render-to-string ssr

Last synced: about 2 months ago
JSON representation

Render ArrowJS templates and partials to string. (Deno, Node, Bun, Browser)

Awesome Lists containing this project

README

          


Frame 13

![](https://img.shields.io/bundlephobia/min/arrow-render-to-string?display_name=tag&sort=semver&style=flat&colorA=181819&colorB=181819)
![](https://img.shields.io/npm/v/arrow-render-to-string?display_name=tag&sort=semver&style=flat&colorA=181819&colorB=181819)

Render [ArrowJS](http://arrow-js.com) templates and partials to string.

Works wherever JS does.

## Installation

```bash
npm install arrow-render-to-string
```

## Usage/Examples

### Basic

```javascript
import { html } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'

const message = 'Hello World'
const view = html`

${message}

`

renderToString(view) //=>

Hello World


```

### Reactive Variables

```javascript
import { html, reactive } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'

const state = reactive({
count: 0,
})
const view = html`

${() => state.count}

`

renderToString(view) //=>

0


```

### Events

Events are stripped out, for you to re-hydrate on the client

```javascript
import { html, reactive } from '@arrow-js/core'
import { renderToString } from 'arrow-render-to-string'

const state = reactive({
count: 0,
})
const view = html` (state.count += 1)}">
${() => state.count}
`

renderToString(view) //=> ">0
```

## License

[MIT](/LICENSE)