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.
Install using npm:
$ npm install pencil-mustache
Given the following HTML string:
<section>
<h1>{{headline}}h1>
{{{description}}}
section>
and this context:
{
headline: 'Fish & Chips',
description: 'A house specialty!'
}
results in:
<section>
<h1>Fish & Chipsh1>
<span>A house specialty!span>
section>
All together:
var mustache = require('pencil-mustache'),
html = require('./section.html'),
context = {
headline: 'Fish & Chips',
description: 'A house specialty!'
},
template = mustache(html);
document.querySelector('.my-target').innerHtml = template(context);
undefined
and null
with empty stringMIT