Django

Code

Ticket #501 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

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

Reported by: eugene@lazutkin.com Assigned to: adrian
Milestone: Component: RSS framework
Version: 0.90 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

block_super_fix.diff (3.8 kB) - added by django@kieranholland.com on 09/27/05 02:58:38.
A hack for this problem and some unit tests

Change History

09/27/05 02:58:38 changed by django@kieranholland.com

  • attachment block_super_fix.diff added.

A hack for this problem and some unit tests

09/27/05 03:10:58 changed by django@kieranholland.com

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

09/28/05 22:57:44 changed by adrian

  • status changed from new to assigned.

09/28/05 23:22:10 changed by adrian

  • status changed from assigned to closed.
  • resolution set to fixed.

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

07/03/06 02:11:28 changed by anonymous

  • severity changed from normal to minor.
  • component changed from Template system to RSS framework.
  • priority changed from normal to low.
  • version set to 0.9.
  • milestone set to Version 1.0.
  • type changed from defect to enhancement.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted


Add/Change #501 ({{ block.super }} returns value of the most remote ancestor)




Change Properties
Action