Variable substitution/interpolation on string. Look for expressions enclosed in {{ }} braces and substitutes its value with data.
Built for brick and datastore. Supplant is agnostic and can be used as a standalone template engine on both client and server sides. For example, supplant is used by marc to make markdown a dynamic template engine.
with component:
$ component install bredele/supplant
with nodejs:
$ npm install supplant
var Supplant = require('supplant');
var subs = new Supplant();
return the interpolation of a string with an object.
subs.text('my name is {{ name }}', {
name : 'Olivier',
});
// = > my name is Olivier
return uniq identifiers
subs.props('hello {{ name }} and {{other}}');
// => ['name', 'other']
subs.text('{{ company.toUpperCase() }}', {
company : 'github'
});
//GITHUB
supplant
supports grouping, binary operators, identifiers, comparators and ternary operators (see test).
subs.filter('hello', function(str) {
return 'hello ' + str;
});
subs.text('{{ company} | hello}', {
company : 'github'
});
// => hello github
MIT