Opened 10 years ago

Closed 10 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: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 10 years ago.
endblock.2.patch (3.0 KB) - added by Chris Beaven 10 years ago.
The try/except was overkill

Download all attachments as: .zip

Change History (7)

comment:1 Changed 10 years ago by Chris Beaven

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 10 years ago by Adrian Holovaty

Triage Stage: Design decision neededAccepted

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

comment:3 Changed 10 years ago by Chris Beaven

Has patch: set

Here's a good start.

Changed 10 years ago by Chris Beaven

Attachment: endblock.patch added

comment:4 Changed 10 years ago by Chris Beaven

Triage Stage: AcceptedReady for checkin

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

Changed 10 years ago by Chris Beaven

Attachment: endblock.2.patch added

The try/except was overkill

comment:5 Changed 10 years ago by Malcolm Tredinnick

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