From 13e0a64a85f4360d6f66799d39e7a5cba5c7351b Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Thu, 24 Jul 2014 22:50:10 -0700 Subject: [PATCH] Added support for mustaches beginning with @ - Mustaches begining with @ dont have the string attribute defined in the handlebars ast. - If a mustache does not have the string attribute present in hydration_opcode.js, use idName instead. Added missing semicolin for element cache in templates. --- packages/htmlbars-compiler/lib/compiler/hydration.js | 2 +- .../htmlbars-compiler/lib/compiler/hydration_opcode.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/htmlbars-compiler/lib/compiler/hydration.js b/packages/htmlbars-compiler/lib/compiler/hydration.js index b6045d44..ea4ab61b 100644 --- a/packages/htmlbars-compiler/lib/compiler/hydration.js +++ b/packages/htmlbars-compiler/lib/compiler/hydration.js @@ -162,7 +162,7 @@ prototype.pushMustacheInNode = function(name, args, pairs, elementNum) { prototype.shareParent = function(i) { var parentNodesName = "parent" + this.parentCount++; - this.fragmentProcessing.push('var '+parentNodesName+' = '+this.getParent()+'.childNodes['+i+']'); + this.fragmentProcessing.push('var '+parentNodesName+' = '+this.getParent()+'.childNodes['+i+'];'); this.parents.push(parentNodesName); }; diff --git a/packages/htmlbars-compiler/lib/compiler/hydration_opcode.js b/packages/htmlbars-compiler/lib/compiler/hydration_opcode.js index 20636b2f..a2d2a5f3 100644 --- a/packages/htmlbars-compiler/lib/compiler/hydration_opcode.js +++ b/packages/htmlbars-compiler/lib/compiler/hydration_opcode.js @@ -164,9 +164,9 @@ HydrationOpcodeCompiler.prototype.mustache = function(mustache, childIndex, chil this.opcode('program', null, null); processParams(this, mustache.params); processHash(this, mustache.hash); - this.opcode('helper', mustache.id.string, mustache.params.length, mustache.escaped, morphNum); + this.opcode('helper', (mustache.id.string || mustache.id.idName), mustache.params.length, mustache.escaped, morphNum); } else { - this.opcode('ambiguous', mustache.id.string, mustache.escaped, morphNum); + this.opcode('ambiguous', (mustache.id.string || mustache.id.idName), mustache.escaped, morphNum); } }; @@ -175,7 +175,7 @@ HydrationOpcodeCompiler.prototype.sexpr = function(sexpr) { this.opcode('program', null, null); processParams(this, sexpr.params); processHash(this, sexpr.hash); - this.opcode('sexpr', sexpr.id.string, sexpr.params.length); + this.opcode('sexpr', (sexpr.id.string || sexpr.id.idName), sexpr.params.length); }; HydrationOpcodeCompiler.prototype.string = function(str) { @@ -187,9 +187,9 @@ HydrationOpcodeCompiler.prototype.mustacheInAttr = function(mustache) { this.opcode('program', null, null); processParams(this, mustache.params); processHash(this, mustache.hash); - this.opcode('helperAttr', mustache.id.string, mustache.params.length, mustache.escaped); + this.opcode('helperAttr', (mustache.id.string || mustache.id.idName), mustache.params.length, mustache.escaped); } else { - this.opcode('ambiguousAttr', mustache.id.string, mustache.escaped); + this.opcode('ambiguousAttr', (mustache.id.string || mustache.id.idName), mustache.escaped); } };