We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt syntax -- why is this invalid

I have a volt template that's throwing an error (Unexpected ENDIF in...line 16) and I can't understand why:

{% if 0 %}

    {% for item1 in [1,2,3] %}

        {% for item2 in [1,2,3] %}

        {% endfor %}

    {% endfor %}

{% endif %}

{% if 0 %}

{% elseif 1 %}

{% endif %}

Note that the error's line number (16) is referencing the "elseif" statement. Removing either the second for loop (for item2...) or the elseif statement (elseif 1) fixes the issue.

I'm new to phalcon and I'm probably missing something obvious, buy I just can't figure this out. What am I missing here?

Thanks!

-Jeff



554

Looks like this is the same issue as:

https://forum.phalcon.io/discussion/2607/nested-for-combined-with-if-throws-exceptions

I'm using the latest Phalcon. This hasn't been fixed?

I tried to reproduce the issue and it works fine in 2.0.6, could you please post exactly the code that cause you trouble?



554

Interesting -- that is the exact code I'm using. As part of debugging the issue, I reduced the template down to the minimum needed to produce the error. Removing either the second nested {% for %} or the {% elseif %} eliminates the error. Phalcon\Version::get() is telling me I'm also running 2.0.6. Is it possible I have an outdated volt underneath the up-to-date phalcon?

I have the same logical structure and the same issue. Version 3.0.1



43.9k

exact, I've just did the test

I have the same logical structure and the same issue. Version 3.0.1