I'm trying to write an if statement in jinja template
{% for key in data %}
{% if key is 'priority' %}
<p>('Priority: ' + str(data[key])</p>
{% endif %}
{% endfor %}
the statement I'm trying to translate in python is
if key == priority:
print(print('Priority: ' + str(data[key]))
This is the error i'm getting:
TemplateSyntaxError: expected token 'name', got 'string'
Why the loop?
You could simply do this:
{% if 'priority' in data %}
<p>Priority: {{ data['priority'] }}</p>
{% endif %}
When you were originally doing your string comparison, you should have used ==
instead.