search over this in google and looked the official docs of twig, didn't find an answer,
I have this
$data['count'] = $count;//6
in my php code, I want to generate td as much as the $beltCount in the twig file I tried this but it didn't work:
{% for i in count%}
<td> {{ i }}</td>
{% endfor %}
Should I do this in a different way? I didn't find a syntax for this
Thanks
The integer 6 isn't enumerable, it's just a number.
You can however use range(1, count)
or, as stated Teneff in comments, the range operator 1..count
to create an enumerable from 1 to 6 (or whatever value is in count
) :
{% for i in range(1, count) %}
<td> {{ i }}</td>
{% endfor %}
{% for i in 1..count %}
<td> {{ i }}</td>
{% endfor %}
You will find more infos in the documentation