wallet-core/node_modules/gulp-util/lib/template.js

24 lines
636 B
JavaScript
Raw Normal View History

2016-10-10 03:43:44 +02:00
var template = require('lodash.template');
var reEscape = require('lodash._reescape');
var reEvaluate = require('lodash._reevaluate');
2016-10-10 03:43:44 +02:00
var reInterpolate = require('lodash._reinterpolate');
var forcedSettings = {
escape: reEscape,
evaluate: reEvaluate,
2016-10-10 03:43:44 +02:00
interpolate: reInterpolate
};
module.exports = function(tmpl, data) {
var fn = template(tmpl, forcedSettings);
2016-10-10 03:43:44 +02:00
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');
}
2016-10-10 03:43:44 +02:00
return fn(o);
};
return (data ? wrapped(data) : wrapped);
};