String concatenation in Jinja

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

    You can use + if you know all the values are strings. Jinja also provides the ~ operator, which will ensure all values are converted to string first.

    {% set my_string = my_string ~ stuff ~ ', '%}
    

提交回复
热议问题