Django

Code

Ticket #3351 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Add block name to endblock (feature request)

Reported by: yary h <spm-django@yary.ack.org> Assigned to: adrian
Milestone: Component: Template system
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

endblock.patch (3.1 kB) - added by SmileyChris on 02/06/07 00:46:59.
endblock.2.patch (3.0 kB) - added by SmileyChris on 02/06/07 14:38:49.
The try/except was overkill

Change History

01/22/07 19:52:28 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

01/24/07 12:52:22 changed by adrian

  • 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?

02/06/07 00:46:44 changed by SmileyChris

  • has_patch set to 1.

Here's a good start.

02/06/07 00:46:59 changed by SmileyChris

  • attachment endblock.patch added.

02/06/07 00:47:51 changed by SmileyChris

  • stage changed from Accepted to Ready for checkin.

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

02/06/07 14:38:49 changed by SmileyChris

  • attachment endblock.2.patch added.

The try/except was overkill

02/11/07 18:22:22 changed by mtredinnick

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

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


Add/Change #3351 (Add block name to endblock (feature request))




Change Properties
Action