Django - Template with expression

Viewed 5455

In a template I'd like evaluate this expression

assoc = service not in backends.not_associated

And store it in a variable, here is the context:

<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 am I getting this error ?

u'with' received an invalid token: u'not'

It seems with can't evaluate a boolean operation, can it ?

1 Answers
Related