Here is my problem with blocks: #extended {{block a}}hello{{endblock}} world {{block b}}hello{{endblock}}
#extending {{block a}}HELLO{{endblock}} WORLD {{block b}}HELLO{{endblock}} where does WORLD go? It gets lost. Blocks are convenient and not well defined. I believe {{def a():}}HELLO{{return}}, the current web2py way, is more Pythonic and it is better defined. Massimo On Nov 22, 9:46 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > Would blocks be too much to ask for? > > -Thadeus > > On Sun, Nov 22, 2009 at 9:15 AM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Perhaps you are talking about something equivalent to Django blocks? > > We do not have that. > > We have other ways to do a similar thing. There are two basic things > > you can do: > > > 1) Extending > > #extedened.html > > <html><body>{{include}}</body></html> > > > #extending.html > > {{extends 'extended.html'}}<h1>Hello<h1> > > > 2) Including > > #including.html > > <html><body>{{include 'body.html'}}</body></html> > > > #body.html > > <h1>Hello<h1> > > > And you can mix and match. > > You can also pass functions to the extended function > > > Extending > > #extedened.html > > <html><body><h1>{{header()}}</h1>{{include}}<h1>{{footer()}}</h1></ > > body></html> > > > #extending.html > > {{def header():}}This is the header{{return}} > > {{def footer():}}This is the footer{{return}} > > {{extends 'extended.html'}}<h1>Hello<h1> > > > and you can do these things in a try ... except to have a default: > > > <html><body><h1>{{try: header()}}{{except:}}default{{pass}}</h1> > > {{include}}<h1>{{footer()}}</h1></body></html> > > > Massimo > > > On Nov 22, 7:18 am, jensmun <j...@acamedia.org> wrote: > > > Hi, > > > > Typical case of embarrassing situation. I don't know anything about > > > programming and wanted to try this out. Unfortunately I can't even get > > > my head around extensions of views. And I can't seem to find a > > > description of something this basic. > > > > I've tried stripped the example app in web2py from everything but a > > > default controller, two views and the db-model. But I can't get the > > > extension of views to work. And the Welcome-application is far too > > > complicated for somebody like me to understand. > > > > I would be grateful for a pointer to some place which explains view > > > and their extensions. If for example there are two places where I use > > > <h1> how does the extension view know which of these two replace with > > > the <h1> in the extension. > > > > Stupid question I know - but I've been trying to create a model and > > > extension view which changes top "Welcome customize me" and not been > > > succeeding. > > > > And Massimo's manual assumes a lot of this knowledge already I feel - > > > since the examples moves quickly past how extensions change the parent- > > > node. > > > > Grateful for any direction, > > > > Jens > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---