ziplit
v0.1.1
Published
ES6 Template literal strings helper and compiler.
Downloads
9
Maintainers
Readme
Ziplit
Lightweight utility for ES6 Template Literal strings. Template strings are great but creating reusable Template Literals can be challenging. This simple util makes that process painless.
Install
$ npm install ziplit
Usage
Using an actual Template Literal string.
import ziplit from 'ziplit';
const compiled = ziplit.compile`My name is ${'name'}.` // NOTE: single quotes around "name" NOT parens.
const rendered = compiled.render('Milton'); // OR { name: 'Milton' } OR ['Milton']
Using a ziplit formatted string.
import ziplit from 'ziplit';
const compiled = ziplit.compile('My name is ${name}.') // NOTE: calling function with parens.
const rendered = compiled.render('Milton'); // OR { name: 'Milton' } OR ['Milton']
RegExp
You can also change the default RegExp used by ziplit. Just create a new instance and pass in your custom RegExp.
import ziplit from 'ziplit';
const instance = ziplit.create(/{{(.*?)}}/g);
License
See LICENSE.md