npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

twz

1.1.0 • Public • Published

Twz Build Status codecov

🧙 Magic templates

Features

  • Tiny at just 23 loc
  • Based on template strings

Install

$ npm install twz

Usage

const twz = require('twz');
 
twz('<h1>${ emoji }</h1>')({ emoji: '🧙' });

Examples

List

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>

Heading

const twz = require('twz');
 
twz('<h1>${ name }</h1>')({ 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

install

npm i twz

Downloadsweekly downloads

5

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability