Reputation: 3106
I pass the dictionary errs to a jinja template for flask server:
{% if not errs|length equals 0 %}
But, the following error occurs:
TemplateSyntaxError: expected token 'end of statement block', got 'equals'
I tried various combinations but keep getting different errors, so how to compare length of a dictionary in the template if construct?
Upvotes: 10
Views: 18346
Reputation: 14210
This works for me (Jinja 2.7):
{% if {}|length == 0 %}
is zero
{% endif %}
Upvotes: 24