Simplify Path and Sexpr calculated flags

This commit is contained in:
kpdecker
2014-11-27 07:32:15 -06:00
parent 5c921cafeb
commit e1cba432a6
3 changed files with 39 additions and 26 deletions
+2 -21
View File
@@ -69,21 +69,8 @@ var AST = {
this.type = "sexpr";
this.hash = hash;
var id = this.id = rawParams[0];
var params = this.params = rawParams.slice(1);
// a mustache is definitely a helper if:
// * it is an eligible helper, and
// * it has at least one parameter or hash segment
this.isHelper = !!(params.length || hash);
// a mustache is an eligible helper if:
// * its id is simple (a single part, not `this` or `..`)
this.eligibleHelper = this.isHelper || id.isSimple;
// if a mustache is an eligible helper but not a definite
// helper, it is ambiguous, and will be resolved in a later
// pass or at runtime.
this.id = rawParams[0];
this.params = rawParams.slice(1);
},
HashNode: function(pairs, locInfo) {
@@ -111,8 +98,6 @@ var AST = {
} else if (part === '..') {
depth++;
depthString += '../';
} else {
this.isScoped = true;
}
} else {
dig.push(part);
@@ -123,10 +108,6 @@ var AST = {
this.original = (data ? '@' : '') + original;
this.parts = dig;
this.depth = depth;
// an ID is simple if it only has one part, and that part is not
// `..` or `this`.
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
},
StringNode: function(string, locInfo) {