underscore.template

Extracted template from Underscore, use '_.template' without full underscore source.

Usage no npm install needed!

<script type="module">
  import underscoreTemplate from 'https://cdn.skypack.dev/underscore.template';
</script>

README

underscore.template

Extracted template from Underscore, use _.template without full underscore source.

NPM version Downloads Bower version Build Status

underscore.template

Installation

NPM

npm install underscore.template

Bower

bower install underscore.template

Usage

Node.js

var UnderscoreTemplate = require('underscore.template');
var template = UnderscoreTemplate("<b><%- value %></b>");

template({value: 'hello world'});
// <b>hello world</b>

template({value: '<script>'});
// <b>&lt;script&gt;</b>

Browser

Simply download the latest minified version from the dist/ folder. API is available in a global object called UnderscoreTemplate.

<script src="./dist/underscore.template.js"></script>
var template = UnderscoreTemplate("<b><%- value %></b>");

template({value: 'hello world'});
// <b>hello world</b>

Testing

npm test

License

MIT, see the LICENSE file for detail.