Pass open token to MustacheNode for flag parsing

This commit is contained in:
kpdecker
2013-07-29 23:33:56 -05:00
parent 06d94fed56
commit 0cc6e270f9
2 changed files with 9 additions and 9 deletions
+3 -2
View File
@@ -6,11 +6,12 @@ export function ProgramNode(statements, inverse) {
if(inverse) { this.inverse = new ProgramNode(inverse); }
}
export function MustacheNode(rawParams, hash, unescaped) {
export function MustacheNode(rawParams, hash, open) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;
this.escaped = open[2] !== '{' && open[2] !== '&';
var id = this.id = rawParams[0];
var params = this.params = rawParams.slice(1);
+6 -7
View File
@@ -32,11 +32,11 @@ statement
;
openBlock
: OPEN_BLOCK inMustache CLOSE -> new yy.MustacheNode($2[0], $2[1])
: OPEN_BLOCK inMustache CLOSE -> new yy.MustacheNode($2[0], $2[1], $1)
;
openInverse
: OPEN_INVERSE inMustache CLOSE -> new yy.MustacheNode($2[0], $2[1])
: OPEN_INVERSE inMustache CLOSE -> new yy.MustacheNode($2[0], $2[1], $1)
;
closeBlock
@@ -44,11 +44,10 @@ closeBlock
;
mustache
: OPEN inMustache CLOSE {
// Parsing out the '&' escape token at this level saves ~500 bytes after min due to the removal of one parser node.
$$ = new yy.MustacheNode($2[0], $2[1], $1[2] === '&');
}
| OPEN_UNESCAPED inMustache CLOSE_UNESCAPED -> new yy.MustacheNode($2[0], $2[1], true)
// Parsing out the '&' escape token at AST level saves ~500 bytes after min due to the removal of one parser node.
// This also allows for handler unification as all mustache node instances can utilize the same handler
: OPEN inMustache CLOSE -> new yy.MustacheNode($2[0], $2[1], $1)
| OPEN_UNESCAPED inMustache CLOSE_UNESCAPED -> new yy.MustacheNode($2[0], $2[1], $1)
;