[Django] #33311: Disallow overriding parent blocks within conditionals.

3 views
Skip to first unread message

Django

unread,
Nov 23, 2021, 9:20:10 AM11/23/21
to django-...@googlegroups.com
#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.

Django

unread,
Nov 24, 2021, 7:37:07 AM11/24/21
to django-...@googlegroups.com
#33311: Disallow overriding parent blocks within conditionals.
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Template system | Version: 3.2
Severity: Normal | Resolution: duplicate
Keywords: block, conditional, | Triage Stage:
if | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

This is by design, see also discussions in related tickets #13399, #20219,
#24232, and #4529.

Duplicate of #13413,

--
Ticket URL: <https://code.djangoproject.com/ticket/33311#comment:1>

Reply all
Reply to author
Forward
0 new messages