I my template, I want to give a class active
:
<li>{% if data.tab_nid==0 %} class="active" {% endif %} </li>
But when I run the page I get the bellow error:
TemplateSyntaxError: Could not parse the remainder: '==0' from 'data.tab_nid==0'
答案 0 :(得分:4)
{% if data.tab_nid == 0 %}
You should put space before and after ==
答案 1 :(得分:1)
You use ==
to check the value if is equal, you should put space around ==
.
And you can also use ifequal
Just try this:
<li>{% ifequal data.tab_nid 0 %} class="active" {% endifequal %} </li>
From the document, you can find the ifequal & ifnotequal's explain.