Can I bring for example only 12 contents in a for loop that satisfy the condition I want?
{% for i, a in b %}
{% if a.c[0].d == x %}
{% elseif a.c[1].d == y %}
{% endif %}
{% endfor %}
Let's say there are 100 items in b. 60 of them meet one of the if conditions posted. However, as 40 of them do not meet, for example, 7 items come as a result of for loops that rotate 12 times. 5 loops turn empty. However, I want a total of 12 items that meet one of these conditions. Is this possible?
Note: it does not give the right result as follows
{% for i, a in b|slice(0, 12) %}
{% if a.c[0].d == x %}
{% elseif a.c[1].d == y %}
{% endif %}
{% endfor %}