Twz
🧙 Magic templates
Features
- Tiny at just 23 loc
- Based on template strings
Install
$ npm install twz
Usage
const twz = ; emoji: '🧙' ;
Examples
List
const twz = ; const listTemplate = '<ul>${ list.map(n => `<li>${n}</li>`).join('')</ul>'; list: '1' '2' '3' ;// => <ul><li>1</li><li>2</li><li>3</li></ul>
Heading
const twz = ; name: 'my name' ;
API
twz(input)(data)
Returns the rendered template string
.
input
Type: string
A twz string.
data
Type: object
An object representing the template's data.
twz.file(path)(data)
Returns a promise
path
Type: string
The template's path.
data
Type: object
An object representing the template's data.
twz.fileSync(path)(data)
Returns the rendered template string
.
path
Type: string
The template's path.
data
Type: object
An object representing the template's data.
License
MIT © Tobias Herber