Opened 18 years ago

Closed 18 years ago

#3351 closed (fixed)

Add block name to endblock (feature request)

Reported by: yary h <spm-django@…> Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For some large pages, I find it useful to add comments showing the names of the blocks that an "endblock" is for:

{% block outer %}
  .. many lines here ...
  {% block inner %}
    .. etcetera ..
    {% block questions %}
    .. a whole lot of stuff here ..
    {% endblock %} {# questions #}
    ... etc ...
  {% endblock %} {# inner #}
  ... blah ...
{% endblock %} {# outer #}

The {# endblock comments #} help me keep my sanity. What I'd like to do is write:

    {% endblock questions %}
    ... etc ...
  {% endblock inner %}
  ... blah ...
{% endblock outer %}

and have django make sure that the endblocks match with the named block. Helps with the "internal documentation" and helps me see the structure and catch cut/paste errors. The endblock naming would be purely optional, of course!

Attachments (2)

endblock.patch (3.1 KB ) - added by Chris Beaven 18 years ago.
endblock.2.patch (3.0 KB ) - added by Chris Beaven 18 years ago.
The try/except was overkill

Download all attachments as: .zip

Change History (7)

comment:1 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Adrian Holovaty, 18 years ago

Triage Stage: Design decision neededAccepted

This is a good idea, as long as it's optional. Anybody care to write a patch?

comment:3 by Chris Beaven, 18 years ago

Has patch: set

Here's a good start.

by Chris Beaven, 18 years ago

Attachment: endblock.patch added

comment:4 by Chris Beaven, 18 years ago

Triage Stage: AcceptedReady for checkin

Actually, that's probably more than a start. It works for me :)

by Chris Beaven, 18 years ago

Attachment: endblock.2.patch added

The try/except was overkill

comment:5 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [4489]) Fixed #3351 -- Added optional naming of the block in "endblock" tags to ensure
correct nesting. Thanks for the patch, SmileyChris.

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