String concatenation in Jinja

后端 未结 5 507
旧时难觅i
旧时难觅i 2021-02-03 16:52

I just want to loop through an existing list and make a comma delimited string out of it.
Something like this: my_string = \'stuff, stuff, stuff, stuff\'

<
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-03 17:47

    Just another hack can be like this.

    I have Array of strings which I need to concatenate. So I added that array into dictionary and then used it inside for loop which worked.

    {% set dict1 = {'e':''} %}
    {% for i in list1 %}
    {% if dict1.update({'e':dict1.e+":"+i+"/"+i}) %} {% endif %}
    {% endfor %}
    {% set layer_string = dict1['e'] %}
    

提交回复
热议问题