我有一个返回True或False的模板标记。例如:
@register.simple_tag
def is_home(context):
if homepage:
return True
else:
return False
我想使用此标记来更改模板中的图标:
{% if is_home %}
<svg data-src="{% static 'images/cart_white.svg' %}" width="35" height="30"/>
{% else %}
<svg data-src="{% static 'images/cart.svg' %}" width="35" height="30"/>
{% endif %}
但是模板标签不会像这样调用。
只有当我这样称呼它:{%is_home%}它才有效但我不能将结果用于条件。
任何想法如何将结果用于逻辑?