Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Jinja error while comparing string

I'm getting a problem while comparing two string in python:

this is working:

{% for publication in publications %}
        {{ publications[publication].pub_type }}
{% endfor %}

but not this:

{% for publication in publications %}
        {% if publications[publication].pub_type equals "conference_paper" %} 
             class="active" 
         {% endif %}
{% endfor %}

In the above code, I'm just testing something, but its not working

I'm getting this error:

jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: expected token 'end of statement block', got 'equals'
like image 547
Noor Avatar asked Mar 19 '13 11:03

Noor


1 Answers

perhaps you want:

{% if publication.pub_type == "conference_paper" %}
{#                         ^^                    #}

equals is not valid jinja2 syntax

like image 115
SingleNegationElimination Avatar answered Oct 20 '22 01:10

SingleNegationElimination