Skip to content

Commit

Permalink
Added escape option which if set to false disables escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelbsilva committed May 7, 2014
1 parent 9e2d4a7 commit f6d90d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -92,6 +92,12 @@ Default value: `false`

Clears the mustache cache before running the target. Mustache will cache partials by name when running multiple tasks, so this option is usefull if `options.extension`, `options.directory`, or `options.prefix` have been changed between tasks.

### 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:
Expand Down
7 changes: 6 additions & 1 deletion tasks/mustache_render.js
Expand Up @@ -16,7 +16,8 @@ module.exports = function gruntTask(grunt) {
directory : "",
extension : ".mustache",
prefix : "",
clear_cache : false
clear_cache : false,
escape: true
};

/**
Expand Down Expand Up @@ -96,6 +97,10 @@ module.exports = function gruntTask(grunt) {

if (renderer.options.clear_cache) { mustache.clearCache(); }

if (!renderer.options.escape) {
mustache.escape = function (text) { return text; }
}

this.files.forEach(function renderFile(fileData) {
renderer.render(fileData.data, fileData.template, fileData.dest);
});
Expand Down

0 comments on commit f6d90d6

Please sign in to comment.