Haha, I almost feel like on a perl mailing list now :)) Am 31.01.2011 10:05, schrieb Anand Chitipothu: > 2011/1/31 Remco <[email protected]>: >>> You can do it like this: >>> >>> $cond('email' in tvars, "value=" + tvars['email]) >>> >>> You need to add web.cond to template globals to be able to do this. >>> >>> Anand >> >> Thanks for your reply Anand, >> however your suggestion does not work! >> When 'email' is not set in tvars, a KeyError is thrown by Python >> because it needs the tvars['email'] as a function argument. > > How about this? > > $cond('email' in tvars, "value=" + tvars.get('email', '')) > > If you are using Python 2.5+, use can use: > > $("value=" + tvars['email'] if 'email' in tvars else None) > > Anand >
-- http://noobz.cc/ http://digitalfolklore.org/ -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
