handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

[ISSUE - 1121] Change parsing rule of block to disallow multiple else

Open sshailabh opened this issue 1 year ago • 1 comments

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}}

sshailabh avatar Dec 08 '24 21:12 sshailabh

@jknack Would you please take a look at this PR when you get time? Thanks!

sshailabh avatar Dec 08 '24 21:12 sshailabh