I want to use the loop.index
variable in twig to get the corresponding alphabet letter (1 = A, 2 = B, etc).
{% for item in form.items %}
{% set nom_item = 'Item'~loop.index %}
{% endfor %}
How could I do to get alphabet letter in loop ? I can't find a twig function for that.
Simplest solution
{{ range('A','Z')[loop.index0] }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With