Escaped single quotes in hash arguments

This commit is contained in:
Les Hill
2012-09-22 08:09:33 -07:00
parent b5074a88ec
commit a1c9acb8b1
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -195,6 +195,12 @@ describe "Tokenizer" do
result[3].should be_token("STRING", "baz")
end
it "tokenizes mustaches with String params using single quotes as 'OPEN ID ID STRING CLOSE'" do
result = tokenize("{{ foo bar \'baz\' }}")
result.should match_tokens(%w(OPEN ID ID STRING CLOSE))
result[3].should be_token("STRING", "baz")
end
it "tokenizes String params with spaces inside as 'STRING'" do
result = tokenize("{{ foo bar \"baz bat\" }}")
result.should match_tokens(%w(OPEN ID ID STRING CLOSE))
@@ -207,6 +213,12 @@ describe "Tokenizer" do
result[2].should be_token("STRING", %{bar"baz})
end
it "tokenizes String params using single quotes with escapes quotes as 'STRING'" do
result = tokenize(%|{{ foo 'bar\\'baz' }}|)
result.should match_tokens(%w(OPEN ID STRING CLOSE))
result[2].should be_token("STRING", %{bar'baz})
end
it "tokenizes numbers" do
result = tokenize(%|{{ foo 1 }}|)
result.should match_tokens(%w(OPEN ID INTEGER CLOSE))
+1 -1
View File
@@ -35,7 +35,7 @@
<mu>"}}}" { this.popState(); return 'CLOSE'; }
<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>"'"("\\"[']|[^'])*"'" { 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'; }