just-template
v2.2.0
Published
interpolate a string with variables
Downloads
4,766
Maintainers
Readme
just-template
Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.
npm install just-template
yarn add just-template
Interpolate a string with variables
import template from 'just-template';
var data = {
a: {
aa: {
aaa: 'apple',
bbb: 'pear'
},
bb: 'orange'
},
b: 'plum'
};
template('2 {{a.aa.aaa}}s, a {{a.aa.bbb}}, 3 {{a.bb}}s and a {{b}}. Yes 1 {{a.aa.bbb}}.', data);
// '2 apples, a pear, 3 oranges and a plum. Yes 1 pear.'