diff options
author | kpdecker <kpdecker@gmail.com> | 2013-05-27 14:40:52 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-05-27 14:40:52 -0500 |
commit | 822a8911ecd4ffe822fd82afbf7b24704e79f787 (patch) | |
tree | 4f72b0d6a06522f6b25c25e2f46da711d3daf10d /src | |
parent | 5f349913aa1e3efebcd0a6835d33161c7c81d7a9 (diff) | |
download | handlebars.js-822a8911ecd4ffe822fd82afbf7b24704e79f787.zip handlebars.js-822a8911ecd4ffe822fd82afbf7b24704e79f787.tar.gz handlebars.js-822a8911ecd4ffe822fd82afbf7b24704e79f787.tar.bz2 |
Add support for complex ids in @data references
Diffstat (limited to 'src')
-rw-r--r-- | src/handlebars.l | 2 | ||||
-rw-r--r-- | src/handlebars.yy | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/handlebars.l b/src/handlebars.l index 349e78f..7fcf86e 100644 --- a/src/handlebars.l +++ b/src/handlebars.l @@ -40,7 +40,7 @@ <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'; } -<mu>"@"[a-zA-Z]+ { yytext = yytext.substr(1); return 'DATA'; } +<mu>"@" { return 'DATA'; } <mu>"true"/[}\s] { return 'BOOLEAN'; } <mu>"false"/[}\s] { return 'BOOLEAN'; } <mu>\-?[0-9]+/[}\s] { return 'INTEGER'; } diff --git a/src/handlebars.yy b/src/handlebars.yy index 7ab0153..7e6321f 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -61,7 +61,7 @@ inMustache | path params { $$ = [[$1].concat($2), null]; } | path hash { $$ = [[$1], $2]; } | path { $$ = [[$1], null]; } - | DATA { $$ = [[new yy.DataNode($1)], null]; } + | dataName { $$ = [[$1], null]; } ; params @@ -74,7 +74,7 @@ param | STRING { $$ = new yy.StringNode($1); } | INTEGER { $$ = new yy.IntegerNode($1); } | BOOLEAN { $$ = new yy.BooleanNode($1); } - | DATA { $$ = new yy.DataNode($1); } + | dataName { $$ = $1; } ; hash @@ -91,13 +91,17 @@ hashSegment | ID EQUALS STRING { $$ = [$1, new yy.StringNode($3)]; } | ID EQUALS INTEGER { $$ = [$1, new yy.IntegerNode($3)]; } | ID EQUALS BOOLEAN { $$ = [$1, new yy.BooleanNode($3)]; } - | ID EQUALS DATA { $$ = [$1, new yy.DataNode($3)]; } + | ID EQUALS dataName { $$ = [$1, $3]; } ; partialName : PARTIAL_NAME { $$ = new yy.PartialNameNode($1); } ; +dataName + : DATA path { $$ = new yy.DataNode($2); } + ; + path : pathSegments { $$ = new yy.IdNode($1); } ; |