Helpers are callable objects that take arguments, and you cannot use an if 
statement as an argument in Python. However, you can use a conditional 
expression, so the following should work:
 
*[TR(TD(row.DBQuery.ExampleName), _class='Test1' if row.DBQuery.Value==1 
else 'Test2') for row in query]
 
 
See 
http://docs.python.org/reference/expressions.html#conditional-expressions.
 
Anthony

On Wednesday, June 29, 2011 9:22:58 AM UTC-4, Christian Degenkolb wrote:

> Hi 
>
> is it possible to use conditions in HTMl Helpers like TABLE()? 
>
> for example I build a HTML table with 
>
> tablehelper = TABLE( 
> TR( TD(TD(B("Example"))), 
> *[ TR(  TD( row.DBQuery.ExampleName) ) for row in query] 
> ) 
>
> now is it possible to do something like? 
> tablehelper = TABLE( 
> TR( TD(TD(B("Example"))), 
> *[ TR(  TD( row.DBQuery.ExampleName), if row.DBQuery.Value == 1: 
> _class='Test1' else: _class='Test2' ) for row in query] 
> ) 
>
> I couldnt find anything in the manual regardding this problem. 
>
> with regards 
> christian

Reply via email to