mattacular / grunt-handlebars-compiler

Grunt.js task to precompile Handlebars.js templates with the same options as the CLI utility
MIT License
12 stars 12 forks source link

test suite failing out of the box #3

Closed atuttle closed 10 years ago

atuttle commented 10 years ago
$ grunt test
Running "clean:tests" (clean) task
Cleaning "tmp"...OK

Running "handlebars:vanilla" (handlebars) task
File "tmp/out.compiled.js" created.

Running "handlebars:namespace" (handlebars) task
File "tmp/out-namespace.compiled.js" created.

Running "handlebars:templateRoot" (handlebars) task
Found templateRoot and stripped it from the template name: "World.handlebars"
File "tmp/out-templateRoot.compiled.js" created.

Running "handlebars:exportAMD" (handlebars) task
Compiling as AMD/RequireJS module(s).
File "tmp/out-exportAMD.compiled.js" created.

Running "handlebars:exportCommonJS" (handlebars) task
Compiling as Common JS module(s).
File "tmp/out-exportCommonJS.compiled.js" created.

Running "handlebars:knownHelpers" (handlebars) task
Compiling with known helpers:
>> if, each
File "tmp/out-knownHelpers.compiled.js" created.

Running "nodeunit:tests" (nodeunit) task
Testing handlebars_test.jsF
>> handlebars
>> Message: The vanilla (no options) compiled output should match the clean (prepped) build
>> Error: '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());' == '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

>> handlebars
>> Message: The namespace compiled output should match the clean (prepped) build
>> Error: '(function() {\nvar template = Handlebars.template, templates = myApp.templates = myApp.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());' == '(function() {\nvar template = Handlebars.template, templates = myApp.templates = myApp.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

>> handlebars
>> Message: The output compiled as a AMD module should match the clean (prepped) build
>> Error: 'define([\'handlebars\'], function (Handlebars) {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n});' == 'define([\'handlebars\'], function (Handlebars) {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n});'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

>> handlebars
>> Message: The output compiled as a Common JS module should match the clean (prepped) build
>> Error: 'var Handlebars = require(\'handlebars\');\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n' == 'var Handlebars = require(\'handlebars\');\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

>> handlebars
>> Message: The templateRoot should have been stripped to match the clean (prepped) build
>> Error: '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'World\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());' == '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'World\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

>> handlebars
>> Message: The output compiled with known helpers should match the clean (prepped) build
>> Error: '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld-helpers\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [4,\'>= 1.0.0\'];\nhelpers = this.merge(helpers, Handlebars.helpers); data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;\n\nfunction program1(depth0,data) {\n  \n  var buffer = "", stack1;\n  buffer += "\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.message); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t\t";\n  return buffer;\n  }\n\nfunction program3(depth0,data) {\n  \n  var buffer = "";\n  buffer += "\\n\t\t<p>"\n    + escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0))\n    + "</p>\\n\t\t";\n  return buffer;\n  }\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = (depth0 && depth0.doctype); stack1 = typeof stack1 === functionType ? stack1.call(depth0, {hash:{},data:data}) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t";\n  stack1 = helpers[\'if\'].call(depth0, (depth0 && depth0.message), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});\n  if(stack1 || stack1 === 0) { buffer += stack1; }\n  buffer += "\\n\\n\t\t";\n  stack1 = helpers.each.call(depth0, (depth0 && depth0.messages), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});\n  if(stack1 || stack1 === 0) { buffer += stack1; }\n  buffer += "\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());' == '(function() {\nvar template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'helloWorld-helpers\'] = template(function (Handlebars,depth0,helpers,partials,data) {\n  this.compilerInfo = [2,\'>= 1.0.0-rc.3\'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;\n\nfunction program1(depth0,data) {\n  \n  var buffer = "", stack1;\n  buffer += "\\n\t\t<div>Hello world! ";\n  if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + "</div>\\n\t\t";\n  return buffer;\n  }\n\nfunction program3(depth0,data) {\n  \n  var buffer = "";\n  buffer += "\\n\t\t<p>"\n    + escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0))\n    + "</p>\\n\t\t";\n  return buffer;\n  }\n\n  buffer += "<!doctype ";\n  if (stack1 = helpers.doctype) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n  else { stack1 = depth0.doctype; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n  buffer += escapeExpression(stack1)\n    + ">\\n<html>\\n\t<body>\\n\t\t";\n  stack1 = helpers[\'if\'].call(depth0, depth0.message, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});\n  if(stack1 || stack1 === 0) { buffer += stack1; }\n  buffer += "\\n\\n\t\t";\n  stack1 = helpers.each.call(depth0, depth0.messages, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});\n  if(stack1 || stack1 === 0) { buffer += stack1; }\n  buffer += "\\n\t</body>\\n</html>";\n  return buffer;\n  });\n}());'
>> at Object.exports.handlebars (test/handlebars_test.js:51:8)

Warning: 6/6 assertions failed (94ms) Use --force to continue.

Aborted due to warnings.
mattacular commented 10 years ago

A new version of Handlebars came out that compiles slightly different. I regenerated the tests. Thanks!