Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding handlebars compilations options support #73

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion tasks/handlebars.js
Expand Up @@ -30,6 +30,10 @@ module.exports = function(grunt) {
grunt.registerMultiTask("handlebars", "Compile handlebars templates and partials.", function() { grunt.registerMultiTask("handlebars", "Compile handlebars templates and partials.", function() {


var options = grunt.helper("options", this, {namespace: "JST"}); var options = grunt.helper("options", this, {namespace: "JST"});
var handlebarsOptions ={};
if(!!this.data.handlebarsOptions){
handlebarsOptions=this.data.handlebarsOptions;
};


grunt.verbose.writeflags(options, "Options"); grunt.verbose.writeflags(options, "Options");


Expand All @@ -56,7 +60,7 @@ module.exports = function(grunt) {
src = grunt.file.read(file); src = grunt.file.read(file);


try { try {
compiled = require("handlebars").precompile(src); compiled = require("handlebars").precompile(src,handlebarsOptions);
// if configured to, wrap template in Handlebars.template call // if configured to, wrap template in Handlebars.template call
if(options.wrapped) { if(options.wrapped) {
compiled = "Handlebars.template("+compiled+")"; compiled = "Handlebars.template("+compiled+")";
Expand Down