pencil-mustache
v1.1.0
Published
Simple mustache-style string interpolation
Downloads
1
Maintainers
Readme
pencil-mustache
Simple mustache-style string interpolation.
pencil-mustache is an ultra-minimal mustache-style interpolation micro library. It only implements simple interpolation of double and triple-mustache placeholder expressions (the former being escaped). No pre-compiling. No caching. No partials. No helpers.
Installation
Install using npm:
$ npm install pencil-mustache
Usage
Given the following HTML string:
<section>
<h1>{{headline}}</h1>
{{{description}}}
</section>
and this context:
{
headline: 'Fish & Chips',
description: '<span>A house specialty!</span>'
}
results in:
<section>
<h1>Fish & Chips</h1>
<span>A house specialty!</span>
</section>
All together:
var mustache = require('pencil-mustache'),
html = require('./section.html'),
context = {
headline: 'Fish & Chips',
description: '<span>A house specialty!</span>'
},
template = mustache(html);
document.querySelector('.my-target').innerHtml = template(context);
Changelog
1.1.0
- Changed: replace
undefined
andnull
with empty string
1.0.0
- Initial release
License
MIT