How can I use loop.index in this code.
{% for veri in data %}
<li>no: {{loop.index}}</li>
{% for inveri in datain %}
<li>no: {{loop.index}}</li>
{% endfor %}
{% endfor %}
.....
How can I use loop.index in this code.
{% for veri in data %}
<li>no: {{loop.index}}</li>
{% for inveri in datain %}
<li>no: {{loop.index}}</li>
{% endfor %}
{% endfor %}
.....
As pointed out by Goto u need to use loop.parent.loop as seen here
{% set data = [1,2,3,4,5,] %}
{% for d in data %}
{{ loop.index0 * (data|length + 1) + 1 }}
{% for d in data %}
{{ loop.parent.loop.index0 * (data|length + 1) + 1 + loop.index }}
{% endfor %}
{% endfor %}
{% set data = [1,2,3,4,5,] %}
{% set data2 = [1,2,3,4,5,6,7,8,9] %}
{% for d in data %}
{{ loop.index0 * (data2|length + 1) + 1 }}
{% for d in data2 %}
{{ loop.parent.loop.index0 * (data2|length + 1) + 1 + loop.index }}
{% endfor %}
{% endfor %}
data and data2. This is StackOverflow, don't expect us to do all your work. Anticipate on the provided answer and try to use them in your own code. Don't expect answers you just can copy/paste and be done with itDo you want something like this?
{% set data = [1, 2, 3, 4, 5] %}
{% set data2 = [1, 2, 3] %}
{% set i = 1 %}
{% for d in data %}
{{ i }}
{% set i = i + 1 %}
{% for d2 in data2 %}
{{ i }}
{% set i = i + 1 %}
{% endfor %}
{% endfor %}