Why doesn't my condition logic work as expected in Jinja2/CherryPy?

前端 未结 5 1762
春和景丽
春和景丽 2021-01-01 13:10
{% if bCat2 == True %}
    
True
{% else %}
False

Returns

False
5条回答
  •  独厮守ぢ
    2021-01-01 13:15

    This part of documentation can help you:

    The special constants true, false and none are indeed lowercase. Because that caused confusion in the past, when writing True expands to an undefined variable that is considered false, all three of them can be written in title case too (True, False, and None). However for consistency (all Jinja identifiers are lowercase) you should use the lowercase versions.

    Source: http://jinja.pocoo.org/docs/templates/

    Try that code:

    {% if bCat2 == true %}
    
    True
    {% else %}
    False
    {% endif %}

提交回复
热议问题