traverse-template
v1.0.0
Published
Traverse object for templating values
Downloads
3
Maintainers
Readme
traverse-template
Traverse object for templating values
Install
npm
$ npm install traverse-template
Usage
Basic
var obj = traverseTemplate({
greeting: 'Hello',
hello_tony: '${greeting} Tony'
})
// Will output
{
greeting: 'Hello',
hello_tony: 'Hello Tony'
}
With given locals
var obj = traverseTemplate({
hello_tony: '${greeting} Tony'
}, {
greeting: 'Hello'
})
// Will output
{
bar: 'Hello Tony'
}
Nested support
var obj = traverseTemplate({
greets: [
'${greeting} Tony',
'${greeting} Boy'
],
foo: {
bar: '${greeting}'
}
}, {
greeting: 'Hello'
})
// Will output
{
greets: [
'Hello Tony',
'Hello Body'
],
foo: {
bar: 'Hello'
}
}
License
Released under the MIT Licence