Add {{{{ }}}} for raw blocks

This commit is contained in:
Jesse Ezell
2013-07-11 12:28:37 -07:00
committed by kpdecker
parent 7a7ad74ff1
commit 954253305a
3 changed files with 15 additions and 1 deletions
+8
View File
@@ -21,6 +21,14 @@ describe('blocks', function() {
equal(result, "0. goodbye! 1. Goodbye! 2. GOODBYE! cruel world!", "The @index variable is used");
});
it("raw block", function() {
var string = "{{{{ {{test}} }}}}";
var hash = { test: "hello" };
shouldCompileTo(string, hash, " {{test}} ",
"raw block ignores blocks");
});
it("empty block", function() {
var string = "{{#goodbyes}}{{/goodbyes}}cruel {{world}}!";
var hash = {goodbyes: [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}], world: "world"};
+5
View File
@@ -54,6 +54,11 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD}
<mu>"(" return 'OPEN_SEXPR';
<mu>")" return 'CLOSE_SEXPR';
<mu>"{{{{"[^\x00]*"}}}}" {
yytext = yytext.substr(4, yyleng-8);
this.popState();
return 'RAW_BLOCK';
}
<mu>"{{"{LEFT_STRIP}?">" return 'OPEN_PARTIAL';
<mu>"{{"{LEFT_STRIP}?"#" return 'OPEN_BLOCK';
<mu>"{{"{LEFT_STRIP}?"/" return 'OPEN_ENDBLOCK';
+2 -1
View File
@@ -35,7 +35,8 @@ statements
;
statement
: openInverse program closeBlock -> new yy.BlockNode($1, $2.inverse, $2, $3, @$)
: RAW_BLOCK { $$ = new yy.ContentNode($1, @$); }
| openInverse program closeBlock -> new yy.BlockNode($1, $2.inverse, $2, $3, @$)
| openBlock program closeBlock -> new yy.BlockNode($1, $2, $2.inverse, $3, @$)
| mustache -> $1
| partial -> $1