Reputation: 711
Before showing a text I have to evaluate it.
Instead of
{% if value %} text_true {% else %} text_false {% endif %}
Are there anything like:
{{ text_true if value else text_false }}
Upvotes: 0
Views: 702
Reputation: 308939
For the example in your question, you can use the yesno
filter
{{ value|yesno:'text_true,text_false' }}
Upvotes: 2
Reputation: 2153
Not with this exact syntax, but there are the default
and default_if_none
template filters. Those may be what you're looking for.
https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#default
Upvotes: 0