summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/ast.js
diff options
context:
space:
mode:
authorKevin Decker <kpdecker@gmail.com>2013-12-30 16:09:41 -0800
committerKevin Decker <kpdecker@gmail.com>2013-12-30 16:09:41 -0800
commita2ca31bb193c5c6f073cfeef023feb9cc0e98ce5 (patch)
treeb96b31bd41c1a6c86f45e114b100c124f8217e6f /lib/handlebars/compiler/ast.js
parentac98e7b177095be80fc5d590d15b4724dd731cab (diff)
parentb09333db7946d20ba7dbc6d32d5496ab8295b8e1 (diff)
downloadhandlebars.js-a2ca31bb193c5c6f073cfeef023feb9cc0e98ce5.zip
handlebars.js-a2ca31bb193c5c6f073cfeef023feb9cc0e98ce5.tar.gz
handlebars.js-a2ca31bb193c5c6f073cfeef023feb9cc0e98ce5.tar.bz2
Merge pull request #690 from machty/subsexpr
Added support for subexpressions
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r--lib/handlebars/compiler/ast.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index b6c3a03..ce5ee11 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -46,7 +46,6 @@ var AST = {
MustacheNode: function(rawParams, hash, open, strip, locInfo) {
LocationInfo.call(this, locInfo);
this.type = "mustache";
- this.hash = hash;
this.strip = strip;
// Open may be a string parsed from the parser or a passed boolean flag
@@ -58,6 +57,25 @@ var AST = {
this.escaped = !!open;
}
+ if (rawParams instanceof AST.SexprNode) {
+ this.sexpr = rawParams;
+ } else {
+ // Support old AST API
+ this.sexpr = new AST.SexprNode(rawParams, hash);
+ }
+
+ // Support old AST API that stored this info in MustacheNode
+ this.id = this.sexpr.id;
+ this.params = this.sexpr.params;
+ this.hash = this.sexpr.hash;
+ this.eligibleHelper = this.sexpr.eligibleHelper;
+ this.isHelper = this.sexpr.isHelper;
+ },
+
+ SexprNode: function(rawParams, hash) {
+ this.type = "sexpr";
+ this.hash = hash;
+
var id = this.id = rawParams[0];
var params = this.params = rawParams.slice(1);
@@ -84,8 +102,8 @@ var AST = {
},
BlockNode: function(mustache, program, inverse, close, locInfo) {
- if(mustache.id.original !== close.path.original) {
- throw new Exception(mustache.id.original + " doesn't match " + close.path.original);
+ if(mustache.sexpr.id.original !== close.path.original) {
+ throw new Exception(mustache.sexpr.id.original + " doesn't match " + close.path.original);
}
LocationInfo.call(this, locInfo);