summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2012-07-05 22:43:05 -0700
committerYehuda Katz <wycats@gmail.com>2012-07-05 22:43:05 -0700
commit72e05d623c07cc3a812528d52fb6d325134efee4 (patch)
tree8eec0d2b12cb9faaeea22a76fd0c045457669f7c /src
parentff1547ea049e5b4b499dfa8d4d450567a91f5505 (diff)
downloadhandlebars.js-72e05d623c07cc3a812528d52fb6d325134efee4.zip
handlebars.js-72e05d623c07cc3a812528d52fb6d325134efee4.tar.gz
handlebars.js-72e05d623c07cc3a812528d52fb6d325134efee4.tar.bz2
Add support for @data variables
Diffstat (limited to 'src')
-rw-r--r--src/handlebars.l1
-rw-r--r--src/handlebars.yy3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/handlebars.l b/src/handlebars.l
index 592fd5c..f81fcdb 100644
--- a/src/handlebars.l
+++ b/src/handlebars.l
@@ -31,6 +31,7 @@
<mu>"}}}" { this.popState(); return 'CLOSE'; }
<mu>"}}" { this.popState(); return 'CLOSE'; }
<mu>'"'("\\"["]|[^"])*'"' { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; }
+<mu>"@"[a-zA-Z]+ { yytext = yytext.substr(1); 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 ec4fbe1..70b7777 100644
--- a/src/handlebars.yy
+++ b/src/handlebars.yy
@@ -58,6 +58,7 @@ inMustache
| path params { $$ = [[$1].concat($2), null]; }
| path hash { $$ = [[$1], $2]; }
| path { $$ = [[$1], null]; }
+ | DATA { $$ = [[new yy.DataNode($1)], null]; }
;
params
@@ -70,6 +71,7 @@ param
| STRING { $$ = new yy.StringNode($1); }
| INTEGER { $$ = new yy.IntegerNode($1); }
| BOOLEAN { $$ = new yy.BooleanNode($1); }
+ | DATA { $$ = new yy.DataNode($1); }
;
hash
@@ -86,6 +88,7 @@ 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)]; }
;
path