Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for else control structure doesn't seem to be supported #1061

Open
weinzierl opened this issue Apr 28, 2023 · 1 comment
Open

for else control structure doesn't seem to be supported #1061

weinzierl opened this issue Apr 28, 2023 · 1 comment

Comments

@weinzierl
Copy link

The following should render "no users found" only in case users is empty.

<ul>
{% for user in users %}
    <li>{{ user.username|e }}</li>
{% else %}
    <li><em>no users found</em></li>
{% endfor %}
</ul>

This is according to the documentation and my tests confirm it.

Jinjava 2.7.0 renders "no users found" in every loop iteration, as if the "{% else %}" would not exist and the loop end at the "{% endfor %}".

@mattcoley
Copy link
Collaborator

Interesting I haven't come across this structure before. Should be straightforward to implement here https://github.com/HubSpot/jinjava/blob/master/src/main/java/com/hubspot/jinjava/lib/tag/ForTag.java#L250 when someone gets some free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants