substituter
v1.3.0
Published
Simple substitution for Node.js
Downloads
916
Maintainers
Readme
substituter
Simple substitution for Node.js
Installation
Install via npm as follows:
$ npm install substituter --save
Usage
Substitute any object property into a template string.
var sub = require('substituter'),
fs = require('fs');
var results = sub('Hello ${globe.region}!', { globe: { region: 'world' } });
// Hello world!
results = sub(fs.readFileSync('template.xml'), { val1: 'foo' });
// Does substitution in a Buffer. results is a string.
Substitute any object property into another object.
var sub = require('substituter');
var results = sub({ board: { message: 'Hello ${globe.region}!' }}, { globe: { region: 'world' } });
// { board: { message: 'Hello ${globe.region}!' } }