diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlebars.l | 4 | ||||
-rw-r--r-- | src/handlebars.yy | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/handlebars.l b/src/handlebars.l index 2afd715..aa76eab 100644 --- a/src/handlebars.l +++ b/src/handlebars.l @@ -26,7 +26,7 @@ <mu>"{{^" { return 'OPEN_INVERSE'; } <mu>"{{"\s*"else" { return 'OPEN_INVERSE'; } <mu>"{{{" { return 'OPEN_UNESCAPED'; } -<mu>"{{&" { return 'OPEN_UNESCAPED'; } +<mu>"{{&" { return 'OPEN'; } <mu>"{{!--" { this.popState(); this.begin('com'); } <mu>"{{!"[\s\S]*?"}}" { yytext = yytext.substr(3,yyleng-5); this.popState(); return 'COMMENT'; } <mu>"{{" { return 'OPEN'; } @@ -36,7 +36,7 @@ <mu>".." { return 'ID'; } <mu>[\/.] { return 'SEP'; } <mu>\s+ { /*ignore whitespace*/ } -<mu>"}}}" { this.popState(); return 'CLOSE'; } +<mu>"}}}" { this.popState(); return 'CLOSE_UNESCAPED'; } <mu>"}}" { this.popState(); return 'CLOSE'; } <mu>'"'("\\"["]|[^"])*'"' { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; } <mu>"'"("\\"[']|[^'])*"'" { yytext = yytext.substr(1,yyleng-2).replace(/\\'/g,"'"); return 'STRING'; } diff --git a/src/handlebars.yy b/src/handlebars.yy index e521c2e..56b3b70 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -42,8 +42,11 @@ closeBlock ; mustache - : OPEN inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]); } - | OPEN_UNESCAPED inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1], true); } + : 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); } ; |