forked from gulp-community/gulp-footer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.js
25 lines (20 loc) · 773 Bytes
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//The following content is a 1-1 copy of [email protected]/lib/template.js to preserve full compatibility after the removal of gulp-util.
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);
};