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

Loop property length does not work in 2.7.3 and 2.8dev0 version with if filter #459

Closed
jfmedeirosneto opened this issue Jul 2, 2015 · 1 comment · Fixed by #993
Closed
Milestone

Comments

@jfmedeirosneto
Copy link

jfmedeirosneto commented Jul 2, 2015

Loop property length does not work in 2.7.3 and 2.8dev0 version with if filter
In 2.7.3 does not work when the results of if filter > 1 elements
In 2.8dev0 does not work when the results of if filter == 1 element

test template:

{% set numberList = [0,10,20,30,40,50,60,70,80,90] %}

{% for number in numberList %}
{% if loop.first %}
length {{ loop.length }} revindex {{ loop.revindex }}
{% endif %}
{{ loop.index }} => {{ number }}
{% endfor %}

{% for number in numberList if number < 50 %}
{% if loop.first %}
length {{ loop.length }} revindex {{ loop.revindex }}
{% endif %}
{{ loop.index }} => {{ number }}
{% endfor %}

{% for number in numberList if number < 10 %}
{% if loop.first %}
length {{ loop.length }} revindex {{ loop.revindex }}
{% endif %}
{{ loop.index }} => {{ number }}
{% endfor %}

results 2.7.3

length 10 revindex 10
1 => 0
2 => 10
3 => 20
4 => 30
5 => 40
6 => 50
7 => 60
8 => 70
9 => 80
10 => 90

length 4 revindex 4
1 => 0
2 => 10
3 => 20
4 => 30
5 => 40

length 1 revindex 1
1 => 0

result 2.8dev0

length 10 revindex 10
1 => 0
2 => 10
3 => 20
4 => 30
5 => 40
6 => 50
7 => 60
8 => 70
9 => 80
10 => 90

length 5 revindex 5
1 => 0
2 => 10
3 => 20
4 => 30
5 => 40

length 2 revindex 2
1 => 0
@rbflurry

This comment has been minimized.

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

Successfully merging a pull request may close this issue.

3 participants