#33311: Disallow overriding parent blocks within conditionals.
-------------------------------------+-------------------------------------
Reporter: Nat S | Owner: nobody
Dunn |
Type: | Status: new
Cleanup/optimization |
Component: Template | Version: 3.2
system | Keywords: block, conditional,
Severity: Normal | if
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When a parent block is overridden in an if condition, the overridden
content is output regardless of the truthiness of the condition. For
example:
{{{
{% if False %}
{% block parent %}Foo{% endblock parent %}
{% endif %}
}}}
Foo gets output, which feels wrong. Either this structure should be
disallowed or the behavior should change.
If Django disallows overriding parent blocks within conditionals, then it
would be great if the error message could include a hint describing the
following workaround:
{{{
{% block parent %}
{% if False %}
{% block parent %}Foo{% endblock parent %}
{% else %}
{{ block.super }}
{% endif %}
{% endblock parent %}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33311>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.8354b62c4e04774f0b4277ad570c04d5%40djangoproject.com.