lazy-template

Create template strings that are lazy and reusable.


Keywords
lazy, strings, template, templating, engine
License
MIT
Install
npm install lazy-template@0.2.0

Documentation

lazy-template NPM version Build Status

Create template strings that are lazy and reusable.

const lazy = require('lazy-template');

// Create a lazy template string.
const greet = lazy`Hello ${'subject'}.`;
// Use the returned function to compile.

greet({ subject: 'world' });
// => 'Hello world.'

greet({ subject: 'lazy-template user.' });
// => 'Hello lazy-template user.'

This module is built with pixie, and lets you pass in a second parameter for options.

Installation

$ npm install --save lazy-template

API

lazy

Create the compile function by using the lazy tag on a template string:

const compile = lazy`Hello ${'world'}.`;

compile(data, [options])

Compile the lazy string against some data.

  • data (Object): Data to use in your template.
  • options (Object): Options that are passed to pixie.compile.
const compile = lazy`Hello ${'world'}.`

compile({ world: 'Earth' });
// => 'Hello Earth.'

compile({ world: 'Mars' });
// => 'Hello Mars.'

Returns a string of the compiled contents.

License

MIT © Jamen Marz