🧙 Magic templates
- Tiny at just 23 loc
- Based on tagged template literals
$ npm install twz
const twz = require('twz');
twz('<h1>${ emoji }</h1>')({ emoji: '🧙' });
const twz = require('twz');
const listTemplate = '<ul>${ list.map(n => `<li>${n}</li>`).join('')</ul>';
twz(listTemplate)({ list: [ '1', '2', '3' ] });
// => <ul><li>1</li><li>2</li><li>3</li></ul>
const twz = require('twz');
twz('<h1>${ name }</h1>')({ name: 'my name' });
Returns the rendered template string
.
Type: string
A twz string.
Type: object
An object representing the template's data.
Returns a promise
Type: string
The template's path.
Type: object
An object representing the template's data.
Returns the rendered template string
.
Type: string
The template's path.
Type: object
An object representing the template's data.
MIT © Tobias Herber