blob: c467820f36daea062f618c2118689116616009a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
var template = require('lodash.template');
var reInterpolate = require('lodash._reinterpolate');
var forcedSettings = {
escape: /<%-([\s\S]+?)%>/g,
evaluate: /<%([\s\S]+?)%>/g,
interpolate: reInterpolate
};
module.exports = function(tmpl, data){
var fn = template(tmpl, null, 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);
};
|