#1056 Fixed grammar for nested raw blocks

This commit is contained in:
Eric Nielsen
2015-07-15 14:40:48 -03:00
parent 8c09b3c896
commit 868ef4b309
3 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -70,7 +70,7 @@ export function prepareMustache(path, params, hash, open, strip, locInfo) {
return new this.MustacheStatement(path, params, hash, escaped, strip, this.locInfo(locInfo));
}
export function prepareRawBlock(openRawBlock, content, close, locInfo) {
export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
if (openRawBlock.path.original !== close) {
let errorNode = {loc: openRawBlock.path.loc};
@@ -78,7 +78,7 @@ export function prepareRawBlock(openRawBlock, content, close, locInfo) {
}
locInfo = this.locInfo(locInfo);
let program = new this.Program([content], null, {}, locInfo);
let program = new this.Program(contents, null, {}, locInfo);
return new this.BlockStatement(
openRawBlock.path, openRawBlock.params, openRawBlock.hash,
+9 -3
View File
@@ -49,12 +49,18 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD}
return 'CONTENT';
}
// nested raw block will create stacked 'raw' condition
<raw>"{{{{"/[^/] this.begin('raw'); return 'CONTENT';
<raw>"{{{{/"[^\s!"#%-,\.\/;->@\[-\^`\{-~]+/[=}\s\/.]"}}}}" {
yytext = yytext.substr(5, yyleng-9);
this.popState();
return 'END_RAW_BLOCK';
if (this.conditionStack[this.conditionStack.length-1] === 'raw') {
return 'CONTENT';
} else {
yytext = yytext.substr(5, yyleng-9);
return 'END_RAW_BLOCK';
}
}
<raw>[^\x00]*?/("{{{{/") { return 'CONTENT'; }
<raw>[^\x00]*?/("{{{{") { return 'CONTENT'; }
<com>[\s\S]*?"--"{RIGHT_STRIP}?"}}" {
this.popState();
+1 -1
View File
@@ -26,7 +26,7 @@ content
;
rawBlock
: openRawBlock content END_RAW_BLOCK -> yy.prepareRawBlock($1, $2, $3, @$)
: openRawBlock content+ END_RAW_BLOCK -> yy.prepareRawBlock($1, $2, $3, @$)
;
openRawBlock