summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Marcotte <dmarcotte@gmail.com>2013-08-24 12:18:12 -0700
committerDaniel Marcotte <dmarcotte@gmail.com>2013-10-13 09:03:02 -0400
commit468fa8b6dd743431ac42cc2b6ad351ea4506561d (patch)
treed9fb065092ff50b5ba29e9542f29bb0930926c35 /src
parente9350f29327289b3c9a5950d6392254d43767065 (diff)
downloadhandlebars.js-468fa8b6dd743431ac42cc2b6ad351ea4506561d.zip
handlebars.js-468fa8b6dd743431ac42cc2b6ad351ea4506561d.tar.gz
handlebars.js-468fa8b6dd743431ac42cc2b6ad351ea4506561d.tar.bz2
Fix "\\" escaping
Previously, "\\{{foo}}" would only result in the desired "\fooValue" if it was at the beginning of the file or immediately after a close stache.
Diffstat (limited to 'src')
-rw-r--r--src/handlebars.l12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/handlebars.l b/src/handlebars.l
index 018096b..7593189 100644
--- a/src/handlebars.l
+++ b/src/handlebars.l
@@ -23,10 +23,16 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/[=}\s\/.]
%%
-"\\\\"/("{{") yytext = "\\"; return 'CONTENT';
[^\x00]*?/("{{") {
- if(yytext.slice(-1) !== "\\") this.begin("mu");
- if(yytext.slice(-1) === "\\") strip(0,1), this.begin("emu");
+ if(yytext.slice(-2) === "\\\\") {
+ strip(0,1);
+ this.begin("mu");
+ } else if(yytext.slice(-1) === "\\") {
+ strip(0,1);
+ this.begin("emu");
+ } else {
+ this.begin("mu");
+ }
if(yytext) return 'CONTENT';
}