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'
isshould be used when comparing to a type, e.g.if var is list. In your case you wantkey == 'priority'. - Nicole Whiteif var is listdoes not check ifvaris a list ... it checks ifvaris the exact typelist... injinja2,if var is listlooks for a test namedlist... which is unlikely to exist at all!! - donkopotamustype(var) is list. - Nicole White