summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/ast.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-11-28 17:26:52 -0600
committerkpdecker <kpdecker@gmail.com>2014-11-28 17:26:52 -0600
commit8a6796e5c09686b47945a35826d77680d589d07c (patch)
tree9cb768c41e6c3b3b39f9bcd5072ea9f472d3c1c6 /lib/handlebars/compiler/ast.js
parent95b23095c097447ff4e1059720abfd2132cb9b2d (diff)
downloadhandlebars.js-8a6796e5c09686b47945a35826d77680d589d07c.zip
handlebars.js-8a6796e5c09686b47945a35826d77680d589d07c.tar.gz
handlebars.js-8a6796e5c09686b47945a35826d77680d589d07c.tar.bz2
Move Jison parsing out of AST into helpers
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r--lib/handlebars/compiler/ast.js47
1 files changed, 9 insertions, 38 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index efb4ece..9f25443 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -10,20 +10,12 @@ var AST = {
this.strip = strip;
},
- MustacheStatement: function(rawParams, open, strip, locInfo) {
+ MustacheStatement: function(sexpr, escaped, strip, locInfo) {
this.loc = locInfo;
this.type = 'MustacheStatement';
- this.sexpr = rawParams;
-
- // Open may be a string parsed from the parser or a passed boolean flag
- if (open != null && open.charAt) {
- // Must use charAt to support IE pre-10
- var escapeFlag = open.charAt(3) || open.charAt(2);
- this.escaped = escapeFlag !== '{' && escapeFlag !== '&';
- } else {
- this.escaped = !!open;
- }
+ this.sexpr = sexpr;
+ this.escaped = escaped;
this.strip = strip;
},
@@ -63,43 +55,22 @@ var AST = {
strip.inlineStandalone = true;
},
- SubExpression: function(rawParams, hash, locInfo) {
+ SubExpression: function(path, params, hash, locInfo) {
this.loc = locInfo;
this.type = 'SubExpression';
- this.path = rawParams[0];
- this.params = rawParams.slice(1);
+ this.path = path;
+ this.params = params || [];
this.hash = hash;
},
- PathExpression: function(data, parts, locInfo) {
+ PathExpression: function(data, depth, parts, original, locInfo) {
this.loc = locInfo;
this.type = 'PathExpression';
- var original = '',
- dig = [],
- depth = 0,
- depthString = '';
-
- for(var i=0,l=parts.length; i<l; i++) {
- var part = parts[i].part;
- original += (parts[i].separator || '') + part;
-
- if (part === '..' || part === '.' || part === 'this') {
- if (dig.length > 0) {
- throw new Exception('Invalid path: ' + original, this);
- } else if (part === '..') {
- depth++;
- depthString += '../';
- }
- } else {
- dig.push(part);
- }
- }
-
this.data = data;
- this.original = (data ? '@' : '') + original;
- this.parts = dig;
+ this.original = original;
+ this.parts = parts;
this.depth = depth;
},