#37038: {% extends %}/{% block %} doesn't work as expected with {% partialdef
%}/{%
partial %}
-------------------------------------+-------------------------------------
Reporter: Christophe Henry | Type: Bug
Status: new | Component: Template
| system
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
First, please excuse me if this edge-case is actually documented or if
there's already an issue documenting it.
I recently had the use case where I needed to duplicate a block of buttons
present a the top of a form, to the bottom of it, on a template that was
extended by another to add a few extra buttons.
I wanted to use the newly added `{% partialdef %}` to solve the problem
but realised `{% partialdef %}` and `{% block %}`. Take the flowing
example:
{{{
{% partialdef btns inline %}
{% block btns_block %}
<button type="button">Save</button>
<button type="button">Publish</button>
{% endblock %}
{% endpartialdef %}
<!-- later -->
{% partial btns %}
}}}
And second template extending the previous:
{{{
{% block btns_block %}
<button type="button">Cancel</button>
<button type="button">Save</button>
<button type="button">Publish</button>
{% endblock %}
}}}
In this situation, the partial will be correctly overriden during the
first usage but not during the second. In the extending template, the
cancel button is present at the top of the page but not at the button.
If `{% partialdef %}` is not inline, the cancel button is not even there
at the top of the extending template.
I created a minimal reproducing example to illustrate this problem:
https://github.com/christophehenry/extends-partials-bug.
--
Ticket URL: <https://code.djangoproject.com/ticket/37038>
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 visit
https://groups.google.com/d/msgid/django-updates/0107019d966c4e57-1db46b8c-5ad3-430c-af32-e51dc6728057-000000%40eu-central-1.amazonses.com.