jinja template variable assignment scope
问题 Given the following Jinja snippet {% set sep='' %} {% for stamp in stamp_list -%} {%- for heartbeat in heartbeat_list -%} {%- if heartbeat.name == site.name and heartbeat.stamp == stamp.stamp -%} {{- heartbeat.sc_time -}} {{- sep -}} {% set sep=',' %} [PROOF for new value {{ sep }}] {%- endif -%} {%- endfor -%} {%- endfor %} Look at the sep variable (short for separator) I want to separate the sc_time with comma's.. like 3.13,2.5,1.33,... So I introduce the var sep, which I change in the