jinja2中如何修改多层for循坏外的变量
作者:互联网
{% set ns = namespace(found=false) %}
{% for item in items %}
{% if item.check_something() %}
{% set ns.found = true %}
{% endif %}
* {{ item.title }}
{% endfor %}
Found item having something: {{ ns.found }}
参考文章:https://segmentfault.com/q/1010000011628065
标签:set,false,多层,item,循坏,jinja2,something,found,ns 来源: https://blog.csdn.net/lsyhaoshuai/article/details/120782683