Answer the question
In order to leave comments, you need to log in
How to make a simple loop in Twig while i < n?
Hello, I ran into a very simple problem, but for some reason I can not find the answer in the documentation.
I have a line counter, I need to repeat the iterations of the loop until the desired number is printed.
In the documentation, the following example\
{% for i in 0..10 %}
* {{ i }}
{% endfor %}
Answer the question
In order to leave comments, you need to log in
{#
n разумеется можно задавать и в логике (или в gulp-data, если это сборщик фронта),
это просто переменная
#}
{% set n = 3 %}
{% for i in range(1, n) %}
{{ i }},
{% endfor %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question