下面的代码是我用来学习 jinja2 的示例表单。正如所写,它返回一个错误,指出它无法识别 {% endif %} 标签。为什么会发生这种情况?

<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>

最佳答案

我想你的台词搞混了。您的 endifendfilter 之前,而 iffilter 之前。那只是一个语法错误。

关于python - Jinja2 If 语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1461484/

10-12 22:06
查看更多