Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jinja2 If Statement

Tags:

python

jinja2

The code below is a sample form I'm using to learn jinja2. As written, it returns an error saying that it doesn't recognize the {% endif %} tag. 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>
like image 659
Owen Pierce Avatar asked Sep 22 '09 17:09

Owen Pierce


1 Answers

I think you have your lines mixed up. Your endif comese before endfilter whereas if is before filter. That's just a syntax error.

like image 123
SilentGhost Avatar answered Oct 13 '22 00:10

SilentGhost