【发布时间】:2014-01-02 01:59:17
【问题描述】:
我想在模板中评估这个表达式
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>
我会收到这个错误吗?
u'with' 收到无效令牌:u'not'
似乎with 无法计算布尔运算,是吗?
【问题讨论】: