Hi,

There are essentially two things that you can do with a block:
(1) define it (or redefine it); and (2) insert it somewhere in a
template.  The block tag thus performs different functions depending
on circumstances:
 * If a block tag with the same name exists in an inherited
   template, then the block tag merely (re)defines the block.
 * If no block tag with the same name is inherited, then the block tag 
   at the same time defines the block AND inserts it in the template.

In my opinion, having two substantially different operations under one
label is a cause for confusion. Explicit is better than implicit. I
wonder whether it would be better the distinguish the functionality in
"insblock" and "defblock":

  {% defblock myblock %}
    This is myblock's definition. Possibly re-definition if the block
    has already been defined in an inherited template. It does not
    insert the block in the template.
  {% enddefblock %}

  {% insblock myblock %}  {# This inserts myblock here. #}

  {% defblock myblock2 insert %}
    This is a shortcut: defines myblock2 and inserts it at the same time. 
    It's the same as the existing topmost block tag. Child templates
    should allow it only inside other blocks, otherwise it doesn't
    make sense.
  {% enddefblock %}

  {% block myblock3 %}
    This is the old, deprecated block tag, existing for backwards
    compatibility. It is not clear what it means.
  {% endblock %}

I think that this would solve
http://code.djangoproject.com/ticket/4529 and other similar requests
in a much more natural and intuitive manner. In addition, the absense
of an insblock (or reuse-block) has resulted in my using strange and
unintuitive techniques in my templates (I wanted to define small
blocks in a base template and insert them in different order in child
templates - and "include" would create an undesired mess of many
files). When I tried to find a solution and see what other people had
said about that, I understood that the block tag is double-faced and
confusing.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to