1.0.0 • Published 2 years ago

manivelle v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Manivelle (french for handcrank) is a template engine with first class support for streaming. It's also:

  • Very small, ~110 lines of code.
  • Pure Javascript, no build or compilation step required.
  • Standalone, has no dependencies.
  • Safe, sanitize html by default.

Usage

examples/readme.js

import { html } from "manivelle"

function render(tasks) {
  return html`
    <title>My Todo List</title>
    <meta charset="utf-8">
    ${renderList}
  `;

  async function* renderList() {
    if (tasks.length === 0) {
      yield html`<p>All caught up!</p>`;
    } else {
      yield html`<ul>`;
      for (const task of tasks) {
        yield html`<li>${task}</li>`;
      }
      yield html`</ul>`;
    }
  }
}

const result = render(["Clean the house", "Water the plants"]);

for await (const value of result) {
  console.log(String(value));
}

License

MIT (c) David De Jesus Duarte