twig.js icon indicating copy to clipboard operation
twig.js copied to clipboard

elseif with two spaces triggers exception

Open dfinton opened this issue 6 years ago • 1 comments

The following code triggers a parse error in twig.js (this compiles successfully in its PHP counterpart). Note I've only tested this for the elseif tag. It could affect other tags as well. Removing the extra space after elseif fixes the parse error.

Hi there
{% if true %}
Yup
{% else %}
{% if 1 > 2 %}
This should not print
{% elseif  5 > 2 %}
  This should print
{% endif %}
{% endif %}

Expected behavior: code compiles successfully despite the extra space after elseif Actual behavior: code returns the following error:

TwigException: Unable to parse 'elseif  5 > 2'

Node version 12.13.1 Twig version 1.14.0

dfinton avatar Dec 10 '19 20:12 dfinton