Traverse object for templating values
$ npm install traverse-template
var obj = traverseTemplate({
greeting: 'Hello',
hello_tony: '${greeting} Tony'
})
// Will output
{
greeting: 'Hello',
hello_tony: 'Hello Tony'
}
var obj = traverseTemplate({
hello_tony: '${greeting} Tony'
}, {
greeting: 'Hello'
})
// Will output
{
bar: 'Hello Tony'
}
var obj = traverseTemplate({
greets: [
'${greeting} Tony',
'${greeting} Boy'
],
foo: {
bar: '${greeting}'
}
}, {
greeting: 'Hello'
})
// Will output
{
greets: [
'Hello Tony',
'Hello Body'
],
foo: {
bar: 'Hello'
}
}
Released under the MIT Licence