#33317 closed Cleanup/optimization (fixed)
Add note about not overriding parent blocks within conditionals
Reported by: | Nat S Dunn | Owned by: | Victor |
---|---|---|---|
Component: | Documentation | Version: | 3.2 |
Severity: | Normal | Keywords: | block, if, Template inheritance |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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. But according to Mariusz Felisiak's response at https://code.djangoproject.com/ticket/33311, this is by design.
It would be great if this could be added to the documentation on Template Inheritance.
Change History (7)
comment:2 by , 3 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 2 years ago
Easy pickings: | set |
---|
comment:4 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 2 years ago
Here is a link to my pull request : https://github.com/django/django/pull/15865
comment:6 by , 2 years ago
Has patch: | set |
---|
Note:
See TracTickets
for help on using tickets.
Agreed, a small note may can be helpful.