Replace <@variables@> in text with gobble
npm install gobble-replaceReplace <@variables@> in text with gobble.
First, you need to have gobble installed - see the gobble readme for details. Then,
``bash`
npm i -D gobble-replace
gobblefile.js
`js<@foo@>
var gobble = require( 'gobble' );
module.exports = gobble( 'templates' ).map( 'replace', {
// all instances of and <@answer@> in thetemplates
// files in will be replaced<@object.nested@>
foo: 'bar',
answer: 42,
object: {
nested: 'value' // you can do dot notation
}
// supply custom delimiters
delimiters: [ '<%=', '%>' ]
// generate a sourcemap
sourceMap: true
});
`
Or, if you want to be really anal about keeping options and variables separate...
`js``
var gobble = require( 'gobble' );
module.exports = gobble( 'templates' ).map( 'replace', {
replacements: { foo: 'bar', answer: 42 },
delimiters: [ '<%=', '%>' ],
sourceMap: true
});
MIT. Copyright 2014-15 Rich Harris