简体   繁体   English

Jinja2如果声明

[英]Jinja2 If Statement

The code below is a sample form I'm using to learn jinja2. 下面的代码是我用来学习jinja2的示例表单。 As written, it returns an error saying that it doesn't recognize the {% endif %} tag. 如上所述,它返回一个错误,表示它无法识别{%endif%}标记。 Why does this happen? 为什么会这样?

<html>

Name: {{ name }}
Print {{ num }} times
Color: {{ color }}
{% if convert_to_upper %}Case: Upper
{% elif not convert_to_upper %}Case: Lower{% endif %}




{% for repeats in range(0,num) %}
{% if convert_to_upper %}
{% filter upper %}
{% endif %}
<li><p style="color:{{ color }}">{{ name }}</style></li>
{% endfilter %}
{% endfor %}
</html>

I think you have your lines mixed up. 我想你的线条混乱了。 Your endif comese before endfilter whereas if is before filter . endif之前comese endfilterif是前filter That's just a syntax error. 那只是一个语法错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM