Replace in a template string all values provided in an object
Use NPM to install RepStr:
npm install repstr
//Import dependencies
var rep_str = require('repstr');
//Compile the template string
var str = rep_str('My car is {color}', { color: 'blue'});
//Display in console
console.log(str); //-> My car is blue
Return a new string. Accepts the following arguments:
str
: template string.obj
: an object with all the keys to be replaced in your template string.prefix
(optionally): a string with the prefix of the template variable. Default value is{
.suffix
(optionally): a string with the suffix of the template variable. Default value is}
.
Under the MIT LICENSE.