Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#501 closed enhancement (fixed)

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

Reported by: eugene@… Owned by: adrian
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: UI/UX:

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@… 9 years ago.
A hack for this problem and some unit tests

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by django@…

A hack for this problem and some unit tests

comment:1 Changed 9 years ago by django@…

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 Changed 9 years ago by adrian

  • Status changed from new to assigned

comment:3 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:4 Changed 8 years ago by anonymous

  • Component changed from Template system to RSS framework
  • milestone set to Version 1.0
  • priority changed from normal to low
  • Severity changed from normal to minor
  • Type changed from defect to enhancement
  • Version set to 0.9

comment:5 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.