본문 바로가기
Python

[Python] flask jinja2에서 문자열 합치기

by daewooki 2021. 9. 19.
반응형

https://stackoverflow.com/questions/2061439/string-concatenation-in-jinja

 

String concatenation in Jinja

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' I already know about loop.last, I just need to

stackoverflow.com

 


* jinja2 string concatenation

파이썬 처럼 join 가능

for x in string_list

{{ string_list | join(", ") }} 으로도 가능


기존 문자열을 합칠 때 +를 사용하는데 jinja2에서는 ~ 을 이용해서도 가능

{{ first_name ~ ',' ~ last_name }}



반응형

댓글