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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to