Opened 8 years ago

Closed 8 years ago

#3351 closed (fixed)

Add block name to endblock (feature request)

Reported by: yary h <spm-django@…> Owned by: adrian
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 SmileyChris 8 years ago.
endblock.2.patch (3.0 KB) - added by SmileyChris 8 years ago.
The try/except was overkill

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 8 years ago by adrian

  • Triage Stage changed from Design decision needed to Accepted

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

comment:3 Changed 8 years ago by SmileyChris

  • Has patch set

Here's a good start.

Changed 8 years ago by SmileyChris

comment:4 Changed 8 years ago by SmileyChris

  • Triage Stage changed from Accepted to Ready for checkin

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

Changed 8 years ago by SmileyChris

The try/except was overkill

comment:5 Changed 8 years ago by mtredinnick

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

(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