Actually I began by using functions too. But had some problems (can't remember exactly what), and view functions, even if comprised exclusively of view code didn't really tick my fancy. I much rather extract those snippets of HTML to a module or model file exclusively dedicated to html snippets. In terms of code organization I find that to be a better way of centralizing templates and such - thus making it much simpler to find them for maintenance. Actually, I recently been playing with plugin_wiki and found the same strategy applied. So you just:
{{=ClassOrInstanceFromModels.whateverHTMLBlock()}} Since I mainly use blocks for sidebars I want to conditionally render two alternatives suit me: {{if renderSiderbar:}} {{=ClassOrInstanceFromModels.whateverHTMLForSideBar()}} {{pass}} Which is nice and clean. But I like to have expressed in the main layout that such sidebar may exist. Hence the using template block: {{block right_sidebar}} {{if renderSidebar: # comes from controller right ;-) }} {{=Whatever}} {{pass}} {{end}} Anyway, it is possible the best solution may depend on the situation and individual preferences. On Tue, Jul 19, 2011 at 9:26 PM, Bruno Rocha <rochacbr...@gmail.com> wrote: > I prefer to work in the old way, used when web2py had no block in views. It > is very easy and pure Python code. > > > {{def myblock():}} > <html code></html code> > {{return}} > > So, in any place of views... > > {{=myblock()}} > > Obviouslly in this way you cannot have {{super}} and other cool things, but > it is easy to adjust in pure Python, even using classes.. > >