JSPM

  • Created
  • Published
  • Downloads 3071
  • Score
    100M100P100Q109265F

Process nested Lo-dash templates recursively. Usually templates that are nested in multiple files will not be evaluated.

Package Exports

  • template

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (template) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

template NPM version

Process nested Lo-dash templates recursively. Usually templates that are nested in multiple files will not be evaluated.

Install

Install with npm:

npm i template --save-dev

Usage

template()

template(text, data, [options])

Example:

var template = require('template');

template('Name: <%= name %>', {name: 'Jon'});

Renders to:

Name: Jon

template.read()

To read a file from the file system before processing, use template.read:

template.read('file.md', data, options);

Options

Template supports all Lo-Dash template options, as well as a few extras.

custom delimiters

All of the options from the delims library may be passed to the options object.

For example, this:

template('Hi, my name is template', {name: 'Jon Schlinkert'}, {delims: ['']});

Results in:

Hi, my name is Jon Schlinkert

Valid syntax

Any of the following expressions may be used in templates:

// Strings
"foo"

// Property strings
foo
foo.bar
foo.bar.baz

// Method calls, passed as properties on the data object
one()
two.three()

// Lo-Dash Mixins
_.foo()
_.foo(bar)
_.foo("baz")

Tip

underscore.string

Mixin the methods from underscore.string so they are available on the _.str object.

_.str = require('underscore.string');
_.mixin(_.str.exports());

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on June 28, 2014.