1.0.0 • Published 6 years ago

flora-tmpl v1.0.0

Weekly downloads
43
License
BSD-2-Clause
Repository
-
Last release
6 years ago

flora

flora-tmpl on npm.

Flora Finch, silent film actress

Streaming templates.

Streaming HTML

Why

HTML is a format that can be streamed. Meaning the browser can start parsing and showing parts of a web page before the full thing has been downloaded. Your application probably has things it needs to do that take some time; like make database requests.

Parts of your page depend on this data, but much of it does not. Flora allows you to write templates that get to the client as quickly as possible, because only the parts that need to wait, do wait.

Install

yarn add flora-tmpl

Usage

const { html, map } = require('flora-tmpl');
const streamArray = require('stream-array');

function template({items}) {
  return html`
    <h1>Todos</h1>
    <ul>
      ${map(items, item => (
        html`<li>Item ${item}</li>`
      ))}
    </ul>
  `;
}

template({
  items: streamArray([1, 2, 3])
})
.pipe(...)

License

BSD 2 Clause

1.0.0

6 years ago

0.1.2

6 years ago

0.1.1

7 years ago

0.1.0

7 years ago