Did you see my reply in the py4web group?
--------------------------
If I'm understanding the question correctly, I think I'd do the following:
cell_list = []
cell_list.append(TD("...first td here..."))
cell_list.append(TD("...additional cell..."))
cell_list.append(TD("...additional cell..."))
if var == 1:
cell_list.append('my conditional cell')
cell_list.append(TD("...remaining cells..."))
cell_list.append(TD("...remaining cells..."))
cell_list.append(TD("...remaining cells..."))
Or, if you want to specify all the standard cells at one time...
cell_list = [TD(), TD(), TD(), TD(), TD())
if var == 1:
cell_list.insert(3, TD('conditional cell'))
Does that help?
-Jim
On Monday, April 18, 2022 at 11:20:49 AM UTC-5 Ramos wrote:
> Hello i have my code to generate html base on a condition
>
> one of the table columns should be created only if var =1
>
> this works but the html removes the _class="aa" in case of var==1, and
> does not create the TD if var!=1
> TD(
> ...,
> *(DIV("b",_class="aa") ) if var==1 else tuple())
> ....,
> etc
>
>
> *Using a list*
> If i use a list it shows the _class="aa" in case of var==1 but how do i
> make it to ommit the column in case var!=1 ??
> It creates a blank TD() and that is not what i want
> TD(*[DIV("b",_class="aa") if var==1 else None???])
>
> regards
> António
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/44e0afcd-2e46-4715-9a13-45e0ea5edaban%40googlegroups.com.