Opened 16 years ago

Last modified 10 years ago

#6646 closed

included template blocks are not being overrided by parent template. — at Version 3

Reported by: anonymous Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords: include, extends, block
Cc: michael@…, tom@…, mmitar@…, drackett@…, dueSouth, botondus@…, dev@…, flisky Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

When including a template into a parent template, the child-template's blocks are not overridden by the parent.

For example:

base.html:

{% if is_satchmo %}
{% include "satchmo_base.html" %}
{% else %}
{% include "journal_base.html" %}
{% endif %}

journal_base.html contains the following block:

{% block content%}{% endblock %}

view_template.html extends base.html (with the context variable is_satchmo == False). view_template.html contains {% block content%}{% endblock %} which should filled with data from the view's context variable.

If I rename journal_base.html to base.html - everything works fine - but when I use the version of base.html that relies on the include tag, {% block content %} doesn't get overridden.

The documentation says that context vairables are available to included templates, so not being able to override blocks seems like a bug.

Change History (3)

comment:1 by Collin Grady <cgrady@…>, 16 years ago

Context variables have nothing to do with blocks - as far as I'm aware this is just how the template system works - included templates cannot be extended.

comment:2 by edgarsj, 16 years ago

Component: Template systemDocumentation
Triage Stage: UnreviewedAccepted

Probably documentation needs to clarify this.

comment:3 by Ramiro Morales, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top