#24232: Add conditional expressions to block tag
---------------------------------+--------------------
Reporter: giuliettamasina | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
It would be nice if I could add a conditional expression after a block
name, mimicking the shortcut conditional expression form in Python, to
only render a block if a certain condition is true. So instead of writing
e.g. this:
{{{
{% block title %}
{% if post.title %}
{{ post.title }}
{% else %}
{{ block.super }}
{% endif %}
{% endblock %}
}}}
I could write this:
{{{
{% block title if post.title %}My title{% endif%}
}}}
See also #9173 ([https://code.djangoproject.com/ticket/9173#comment:9
comment 9]) where I first thought of this.
I have some working proof of concept code and could open a pull request to
start working on this, if accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/24232>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.8157872f3ea3778193de2bc4726f8c68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.