Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#501 closed enhancement (fixed)

{{ block.super }} returns value of the most remote ancestor

Reported by: eugene@… Owned by: Adrian Holovaty
Component: contrib.syndication Version: 0.90
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

{{ block.super }} always returns value of the most remote ancestor. Example:

Template A:

{% block abc %}A{% endblock %}

Template B:

{% extends "A" %}
{% block abc %}{{ block.super }}B{% endblock %}

Template C:

{% extends "B" %}
{% block abc %}{{ block.super }}C{% endblock %}

Template A will be rendered as "A", B as "AB", C as "AC". I assume the original intention was to implement a stack of parents, so C would be rendered as "ABC". At least it is documented that way.

template_loader.py doesn't implement stacking order for blocks. Instead it defines two member variables in BlockNode: nodelist, which holds current nodes, and original_node_list, which holds nodes of the farthest ancestor.

Attachments (1)

block_super_fix.diff (3.8 KB ) - added by django@… 19 years ago.
A hack for this problem and some unit tests

Download all attachments as: .zip

Change History (6)

by django@…, 19 years ago

Attachment: block_super_fix.diff added

A hack for this problem and some unit tests

comment:1 by django@…, 19 years ago

I have a set of templates that depend on {{ block.super }} working as described by Eugene. This little hack does the job for me. Even if you think the fix sucks the unit tests may be useful.

Cheers,
Kieran

comment:2 by Adrian Holovaty, 19 years ago

Status: newassigned

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: assignedclosed

(In [715]) Fixed #501 -- Fixed block.super in multi-level templates, and added unit tests to confirm. Thanks for the patch, django@…

comment:4 by anonymous, 18 years ago

Component: Template systemRSS framework
milestone: Version 1.0
priority: normallow
Severity: normalminor
Type: defectenhancement
Version: 0.9

comment:5 by (none), 17 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top