在模板中,我想评估这个表达式
assoc = service not in backends.not_associated
并将其存储在变量中,这是上下文:
<ul class="list-inline">
{% for service in backends.backends %}
{% with assoc=service not in backends.not_associated %}
<li{% if assoc %} class="associated"{% endif %}>
<a rel="nofollow"
href="{% url
'social:'|add:assoc|yesno:'begin,disconnect' service %}"
title="{{ service|title }}">
<img src="{% static 'social_icons/'|add:service|add:'.png' %}" />
</a>
</li>
{% endwith %}
{% endfor %}
</ul>
我是否收到此错误?
你'收到了一个无效的令牌:你不是'
似乎with
无法评估布尔运算,可以吗?