javascript - grunt-contrib-handlebars output is different from handlebars npm task -
my issue similar grunt-contrib-handlebars - output different when run handlebars npm task, no 1 has answered question thought i'd start own.
i'm trying precompile handlebars template files js file. used handlebars npm task manually compile , website works fine npm generated output. run following command:
handlebars *.handlebars -f template.js
which generated following:
(function() { var template = handlebars.template, templates = handlebars.templates = handlebars.templates || {}; templates['address-book-contact-form'] = template(function (handlebars,depth0,helpers,partials,data) { this.compilerinfo = [2,'>= 1.0.0-rc.3']; helpers = helpers || handlebars.helpers; partials = partials || handlebars.partials; data = data || {}; var buffer = "", stack1, stack2, options, functiontype="function", escapeexpression=this.escapeexpression, self=this, helpermissing=helpers.helpermissing; buffer += "<form class=\"dark-bg\">\n <input type=\"hidden\" id=\"propertyid-input\" name=\"propertyid\" value=\""; if (stack1 = helpers.propertyid) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.propertyid; stack1 = typeof stack1 === functiontype ? stack1.apply(depth0) : stack1; } buffer += escapeexpression(stack1) + "\"/>\n\n "; stack1 = self.invokepartial(partials['partial-overlay-nav'], 'partial-overlay-nav', depth0, helpers, partials, data); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n <div class=\"property-fields-wrapper\">\n <fieldset>\n <div class=\"address-book-form row\"> \n \n <div class=\"span3\">\n <h4>info</h4>\n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.inputfield),stack1 ? stack1.call(depth0, "name", "business name", depth0.name, true, options) : helpermissing.call(depth0, "inputfield", "name", "business name", depth0.name, true, options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n "; if (stack2 = helpers.addressbookcontacttypedropdown) { stack2 = stack2.call(depth0, {hash:{},data:data}); } else { stack2 = depth0.addressbookcontacttypedropdown; stack2 = typeof stack2 === functiontype ? stack2.apply(depth0) : stack2; } if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n "; ...
now trying compile template files using grunt grunt-contrib-handlebars. , following output:
handlebars.template(function (handlebars,depth0,helpers,partials,data) { this.compilerinfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, handlebars.helpers); data = data || {}; var stack1, functiontype="function"; if (stack1 = helpers.addressbookcontactformpropertyitem) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.addressbookcontactformpropertyitem; stack1 = typeof stack1 === functiontype ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { return stack1; } else { return ''; } }) handlebars.template(function (handlebars,depth0,helpers,partials,data) { this.compilerinfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, handlebars.helpers); data = data || {}; return "<div class=\"address-book-property-selection-wrapper\">\n <div class=\"dk_container dk_theme_default\" id=\"dk_container_address-book-properties-input\" style=\"display: block;\">\n <a class=\"dk_toggle\"><span class=\"dk_label\">property</span></a>\n </div>\n <div class=\"address-book-properties-container\">\n <div class=\"address-book-properties-search-container\">\n <input type=\"text\" class=\"span3\" id=\"address-book-properties-search-input\" placeholder=\"\" />\n </div>\n <ul class=\"collection\"></ul>\n </div>\n</div>"; }) handlebars.template(function (handlebars,depth0,helpers,partials,data) { this.compilerinfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, handlebars.helpers); partials = this.merge(partials, handlebars.partials); data = data || {}; var buffer = "", stack1, stack2, options, functiontype="function", escapeexpression=this.escapeexpression, self=this, helpermissing=helpers.helpermissing; buffer += "<form class=\"dark-bg\">\n <input type=\"hidden\" id=\"propertyid-input\" name=\"propertyid\" value=\""; if (stack1 = helpers.propertyid) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.propertyid; stack1 = typeof stack1 === functiontype ? stack1.apply(depth0) : stack1; } buffer += escapeexpression(stack1) + "\"/>\n\n "; ...
can shed advice on situation? cannot figure out why outputs different , how make grunt output same manual npm handlebars compile.
outputs different because compiler versions different.
Comments
Post a Comment