ziplit
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

Package Sidebar

Install

npm i ziplit

Weekly Downloads

5

Version

0.1.1

License

ISC

Unpacked Size

25 kB

Total Files

19

Last publish

Collaborators

  • blujedis