Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding support for handlebars compilation options

Some projects need to customize handlebars template precompilation. Now
it can be done by adding the configuration to the grunt.js file. For
example:
handlebars{

	    built: {
	        src: ['app/templates/**/*.html'],
	        dest: 'dist/debug/templates.js',
	        options:{
	        	    data: true,
	        	    stringParams: true
	        	}
	      }
}
  • Loading branch information...
commit 7b75b34c54966ce1e429262d658e10a7f20e8f4e 1 parent 323565a
marcus bronstein authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 tasks/handlebars.js
View
6 tasks/handlebars.js
@@ -30,6 +30,10 @@ module.exports = function(grunt) {
grunt.registerMultiTask("handlebars", "Compile handlebars templates and partials.", function() {
var options = grunt.helper("options", this, {namespace: "JST"});
+ var handlebarsOptions ={};
+ if(!!this.data.handlebarsOptions){
+ handlebarsOptions=this.data.handlebarsOptions;
+ };
grunt.verbose.writeflags(options, "Options");
@@ -56,7 +60,7 @@ module.exports = function(grunt) {
src = grunt.file.read(file);
try {
- compiled = require("handlebars").precompile(src);
+ compiled = require("handlebars").precompile(src,handlebarsOptions);
// if configured to, wrap template in Handlebars.template call
if(options.wrapped) {
compiled = "Handlebars.template("+compiled+")";
Please sign in to comment.
Something went wrong with that request. Please try again.