我想loop.index在树枝中使用变量来获取相应的字母(1 = A,2 = B等)。
{% for item in form.items %}
{% set nom_item = 'Item'~loop.index %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使字母循环?我找不到为此的细枝功能。
try with this!
{% set foo = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] %}
{% for index,item in form.items %}
{% set nom_item = 'Item'~foo[index] %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)