Reputation:
I really face an error in Flask.
When I try to put if statement to insert some elements inside it, a token error saying expected token 'name', got 'integer'
arise.
And when I try to delete if statement then the token error disappears and the entire page with its contents is smoothly displayed.
Below are some of my codes.
Page.html
{% for content in contents %}
<div>
*some divs here*
{{content}}
</div>
{% if content.index is 3 %}
<div>
*some contents inside*
</div>
{% endif %}
{% endfor %}
Upvotes: 1
Views: 1189
Reputation: 1075
In your if
statement condition, you should use ==
rather than is
.
is
is used to compare against the type rather than the value.
Upvotes: 1