[cse491] Jinja2 Template Errors

C. Titus Brown ctb at msu.edu
Tue Sep 22 08:14:08 PDT 2009


On Tue, Sep 22, 2009 at 11:00:56AM -0400, Owen Pierce wrote:
> Titus,
> 
> I can get everything except for the case filter to work.  The code below
> returns a nonsense error message when jinja2_form.py is run:
> "
>   File "/home/frost/Documents/MSU/CSE491/trunk/templates/process_form.html",
> line 13, in template
>     {% elif not convert_to_upper %}
> jinja2.exceptions.TemplateSyntaxError: unknown tag 'elif'
> "
> 
> If I delete the code regarding convert_to_upper in the bottom half of the
> code, there is no problem.  I tried moving around the endfilter tag, it
> didn't work.  What is going on in this code that I don't understand?

You're trying to do the equivalent of this:

   for ...:
     if ...:
       endfor
     endif

--titus

> {% for repeats in range(0,num) %}
> {% if convert_to_upper %}
> {% filter upper %}
> {% elif not convert_to_upper %}
> {% filter lower %}
> {% endif %}
> <li><p style="color:{{ color }}">{{ name }}</style></li>
> {% endfilter %}
> {% endfor %}
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2009 mailing list