diff --git a/README.md b/README.md index 3e17f2f..17cb675 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,12 @@ Default value: `undefined` These two slots can be used to fill in a default `data` or `template` value for any item in your `files` list that does not already have one specified. This can be handy if you want to dynamically build the `files` list and apply the same `data` or `template` source to every item in the list. +### options.escape +Type: `Boolean` +Default value: `true` + +If set to `false` it disables default HTML escaping. That means that `{{var}}` will not be escaped. This is usefull for templating files that are not HTML. + ### Usage Examples For this Grunt config: diff --git a/tasks/mustache_render.js b/tasks/mustache_render.js index 30e19b5..9c7cb85 100644 --- a/tasks/mustache_render.js +++ b/tasks/mustache_render.js @@ -21,7 +21,8 @@ module.exports = function gruntTask(grunt) { prefix : "", // discouraged; use prefix_dir and/or prefix_file prefix_dir : "", prefix_file : "", - clear_cache : false + clear_cache : false, + escape: true }; /** @@ -316,6 +317,10 @@ module.exports = function gruntTask(grunt) { if (renderer.options.clear_cache) { mustache.clearCache(); } + if (!renderer.options.escape) { + mustache.escape = function (text) { return text; } + } + Promise.all(files.map(function renderFile(fileData) { return renderer.render(fileData.data, fileData.template, fileData.dest); })).