Can a Jinja variable's scope extend beyond in an inner block?

后端 未结 8 952
夕颜
夕颜 2020-11-27 06:07

I have the following Jinja template:

{% set mybool = False %}
{% for thing in things %}
    
    {%
8条回答
  •  悲哀的现实
    2020-11-27 06:46

    Update 2018

    As of Jinja 2.10 (8th Nov 2017) there is a namespace() object to address this particular problem. See the official Assignments documentation for more details and an example; the class documentation then illustrates how to assign several values to a namespace.

提交回复
热议问题