diff options
Diffstat (limited to 'node_modules/gulp-util/lib/template.js')
-rw-r--r-- | node_modules/gulp-util/lib/template.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/gulp-util/lib/template.js b/node_modules/gulp-util/lib/template.js new file mode 100644 index 000000000..eef3bb376 --- /dev/null +++ b/node_modules/gulp-util/lib/template.js @@ -0,0 +1,23 @@ +var template = require('lodash.template'); +var reEscape = require('lodash._reescape'); +var reEvaluate = require('lodash._reevaluate'); +var reInterpolate = require('lodash._reinterpolate'); + +var forcedSettings = { + escape: reEscape, + evaluate: reEvaluate, + interpolate: reInterpolate +}; + +module.exports = function(tmpl, data) { + var fn = template(tmpl, forcedSettings); + + var wrapped = function(o) { + if (typeof o === 'undefined' || typeof o.file === 'undefined') { + throw new Error('Failed to provide the current file as "file" to the template'); + } + return fn(o); + }; + + return (data ? wrapped(data) : wrapped); +}; |