Initial commit
[yaffs-website] / node_modules / gulp-util / lib / template.js
1 var template = require('lodash.template');
2 var reEscape = require('lodash._reescape');
3 var reEvaluate = require('lodash._reevaluate');
4 var reInterpolate = require('lodash._reinterpolate');
5
6 var forcedSettings = {
7   escape: reEscape,
8   evaluate: reEvaluate,
9   interpolate: reInterpolate
10 };
11
12 module.exports = function(tmpl, data) {
13   var fn = template(tmpl, forcedSettings);
14
15   var wrapped = function(o) {
16     if (typeof o === 'undefined' || typeof o.file === 'undefined') {
17       throw new Error('Failed to provide the current file as "file" to the template');
18     }
19     return fn(o);
20   };
21
22   return (data ? wrapped(data) : wrapped);
23 };