1👍
✅
You can work with a {% with … %} … {% endwith %}
template tag:
{% with somevar=some.long.expression.with.stuff %}
<div><b>{% if my_condition %}{{ somevar|filter1 }}{% else %}{{ somevar }}{% endif %}</b></div>
{% endwith %}
Source:stackexchange.com