String concatenation in Jinja

后端 未结 5 508
旧时难觅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:48

    If you can't just use filter join but need to perform some operations on the array's entry:

    {% for entry in array %}
    User {{ entry.attribute1 }} has id {{ entry.attribute2 }}
    {% if not loop.last %}, {% endif %}
    {% endfor %}
    

提交回复
热议问题