replace-template-tags
v1.1.1
Published
simple template tag replacement
Downloads
6
Maintainers
Readme
replace-template-tags
simple template tag replacement; allows you to specify a regex and value to use for each replacement
table of contents
installation
npm install replace-template-tags
use
replaceTemplateTags( template, tags )
@param {string|Buffer} template
@param {Array} tags
@param {RegExp} tags.exp
@param {string} tags.value
@returns {string}
basic
var replaceTemplateTags = require( 'replace-template-tags' );
var template = 'simple {function} for your {project} project; create something {project}!';
var tags = [
{
exp: /\{function}/g,
value: 'template tag replacement'
},
{
exp: /\{project}/g,
value: 'awesome'
}
];
result = replaceTemplateTags( template, tags );
// => simple template tag replacement for your awesome project; create something awesome!