I want to add one more comment about the benefit from my previous suggestion.
The worst thing about a dedicated foo.html approach, is that the controller has to feed (sometimes fake) every variables which are mentioned explicitly inside the foo.html, even when in error exit, otherwise you are very likely to get a "global name xxxx is not defined" error. With my suggested generic.html which eliminates the need for a dedicated, decoration foo.html , now I can freely write this kind of code in my controller, without caring foo.html anymore: def foo(): # do something if all_is_ok: # instead of return dict(msg="ok", partA=dataA, partB=dataB), now I do: return dict(DIV(partA,partB)) else: # instead of return dict(msg="oops", partA=dummyA, partB=dummyB), now I do: return dict(whatever="oops") On Nov4, 21:57, Iceberg <[EMAIL PROTECTED]> wrote: > Hi Massimo and all pals, > > This post is about a tiny trick. Hopefully you will like it and > include it in the next version of web2py. > > I used to do this in controller: > > def foo(): > # do something > return dict(partA=some_words_in_a_table, partB=major_part_as_a_form) > > so I need to write a foolish foo.html just to show contents BUT bypass > the display of "partA" and "partB" themselves: > {{extend 'layout.html'}} > {{= partA}} > {{= partB}} > > This is boring. > > Finally, I got an idea and change the generic.html in this way: > > {{extend 'layout.html'}} > {{ # Bypass the _vars key name when there is only one object to be > rendered. }} > {{content = response._vars.values()[0] if len(response._vars)==1 > else response._vars}} > {{=BEAUTIFY(content)}} > > So, in above example, I can write the controller like: > > def bar(): > # do something > return dict( this_key_name_is_invisible = DIV( > some_words_in_a_table, major_part_as_a_form ) ) > > And I don't need the foolish foo.html anymore! > > Hope the above explanation is clear and helpful to some of you. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---