diff options
author | kpdecker <kpdecker@gmail.com> | 2013-07-29 23:33:56 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-10-14 22:50:12 -0500 |
commit | 0cc6e270f971f6ad7e916bfab82e889419affa27 (patch) | |
tree | 0a36e09509741436e4ba3306e398dc27b7deb95b | |
parent | 06d94fed56b43bdf0c824bdce966596e551d3324 (diff) | |
download | handlebars.js-0cc6e270f971f6ad7e916bfab82e889419affa27.zip handlebars.js-0cc6e270f971f6ad7e916bfab82e889419affa27.tar.gz handlebars.js-0cc6e270f971f6ad7e916bfab82e889419affa27.tar.bz2 |
Pass open token to MustacheNode for flag parsing
-rw-r--r-- | lib/handlebars/compiler/ast.js | 5 | ||||
-rw-r--r-- | src/handlebars.yy | 13 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js index 336492d..db7063c 100644 --- a/lib/handlebars/compiler/ast.js +++ b/lib/handlebars/compiler/ast.js @@ -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); diff --git a/src/handlebars.yy b/src/handlebars.yy index d2f24c4..96a5029 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -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) ; |