> No, you are correct. Anything in a child template that is outside of a > {% block %} is ignored....
What about inside a {% block %}? Is it allowed to define an "override" inside another block. In other words would wrapping the offending construct in another block like in: === Derived Template === {%extends "Base Template" %) <%block newblock%} {% for i in list %} {% block a %} current value={{i}} {% endblock %} {% endfor %} {% endblock %} ========== make it valid? I guess not, am I right? To summarize, the {% extends %} can only consist of overriding blocks - no new ones, and inside those, nested blocks are only allowed to define new blocks - no override definitions. Would you agree? On Sep 21, 10:37 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Sep 21, 4:25 pm, Michael Feingold <mfeing...@hill30.com> wrote: > > > > > > > I am somewhat confused about the semantics for nested block > > definitions.Let me explain: > > {% block %} tag serves two purposes a) define a hole (along with the > > default value) to be filled later and b) define the content to replace > > the current value of the hole. > > > As long as we are talking about a) I perfectly understand and have no > > problems with the block tag being nested inside any other tag - > > including for, if, and block itself - anything. If a new value is > > supplied for the block it just placed there instead of whatever is > > already there. > > > Now with b) I am lost. For example, what is the meaning of this: > > > === Base Template === > > ... > > {% block a %} > > ... > > {% endblock %} > > ... > > > === Derived Template === > > {%extends "Base Template" %) > > {% for i in list %} > > {% block a %} > > current value={{i}} > > {% endblock %} > > {% endfor %} > > > ===== > > > What value will be placed in the result? is this even a valid > > construction? > > > It seems to me that the block tags defining the replacement values > > should only be allowed on the top level of the template definition. In > > other words the derived template from the above example should not be > > considered a valid template. > > Am I missing something here? > > No, you are correct. Anything in a child template that is outside of a > {% block %} is ignored. Your derived template is not valid - it may > not actually raise an error, but its behaviour is undefined. > -- > DR.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---