Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
} else if (data !== undefined && template) {
return fileData;
} else {
throw new Error("Please specify data and template for each file");
}
}).filter(Boolean);
if (files.length < 1) {
grunt.log.error("Nothing to do (are sources correctly specified?)");
return;
}
var renderer = new GMR(this.options);
if (renderer.options.clear_cache) { mustache.clearCache(); }
if (renderer.options.escape === true) {
mustache.escape = escapeHtml;
} else if (renderer.options.escape === false) {
mustache.escape = function (text) { return text; };
} else if (typeof renderer.options.escape === 'function') {
mustache.escape = renderer.options.escape;
} else {
throw new Error("escape must be true, false, or a function");
}
var done = (function (gruntDone) {
return function (success) {
mustache.escape = escapeHtml; // do not leak custom escape function
gruntDone(success);
};
function render(obj) {
mustache.clearCache()
return mustache.render(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. In {{cities.1}}, foo is {{nested.foo}}. My favorite book is {{books.0.name}} by {{books.0.author}}. ({{books.0.year}}) is not defined.',
obj
)
}
fs.readFile(this.templatePath, 'utf-8').then((file) => {
this.template = file;
Mustache.clearCache();
Mustache.parse(file);
});
function mustache_render(obj) {
mustache.clearCache()
return mustache.render(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. foo is {{nested.foo}}.',
obj
)
}