handlebars.java
handlebars.java copied to clipboard
[ISSUE - 1121] Change parsing rule of block to disallow multiple else
This PR tries to fix the this issue : https://github.com/jknack/handlebars.java/issues/1121 I am changing the parser grammar of block:
block
:
startToken = START_BLOCK DECORATOR? sexpr blockParams? END
thenBody=body
elseBlock
END_BLOCK nameEnd=QID END
;
elseBlock
:
elseStmtChain*
elseStmt?
;
This would ensure that elseBlock would have 0 or more elseStmtChain with zero or once elseStmt.
Sample example can be found in ParsingErrorTest.java:
{{#if true}} b1 {{else}} b2 {{else}} b3 {{/if}}
@jknack Would you please take a look at this PR when you get time? Thanks!