The concepts of blocks as implemented in Django, in my view, has a
logical problem. Consider this Dango example
#layout.html
{% block A %}nothing{%end block%}...X...{%block B%}nothing{%end block
%}
#someview.html
{% extends 'layout.html' %}
{% block A %}aaa{%end block%}...Y...{%block B%}bbb{%end block %}
It will render as "aaa...X...bbb" where does "...Y..." go? It is lost!
I do not like this.
The web2pyese way to do it is
#layout.html
{{try:}}{{blockA()}}{{except:}}nothing{{pass}}....X....{{try:}}{{blockB
()}}{{except:}}nothing{{pass}}
#someview.html
{{def blockA():}}aaa{{return}}{{def blockB():}}bbb{return}}
{{extend 'layout.html'}}
The web2pyese way has the advatages that:
1) uses only Python syntax
2) no text can be embedded in the page and is lost
3) Blocks are function defined in the extending view (before extend)
therefore they can be passed arguments (while Django blocks cannot).
If the blocks do not need defauld you can replace
#layout.html
{{try:}}{{blockA()}}{{except:}}nothing{{pass}}....X....{{try:}}{{blockB
()}}{{except:}}nothing{{pass}}
with simply
#layout.html
{{blockA()}}...X....{{blockB()}}
You can also
{{include 'otherview.html'}}
Hope this answers the question.
Massimo
On Aug 14, 3:39 am, "Sebastian E. Ovide" <[email protected]>
wrote:
> Hello all,
>
> I was wondering if it is possible to override multiple blocks from an
> extended template.
> Example:http://docs.djangoproject.com/en/dev/topics/templates/#templates
>
> if not, what do you think to implement it ? something like {{include bloc_
> name}} bla bla bla {{pass}}
>
> thanks
> --
>
> Sebastian E. Ovide
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---