> > Here is my python in the controller that builds the table HTML: > > #these three lines are static, but in my code the looping that builds them > is pretty complex eventually with form elements, javascript, and links > htmlrows="<tr><td>row 1 desc</td><td><a href='#'>row 1 > link</a></td><td>a</td></tr>" > htmlrows+="<tr><td>row 2 desc</td><td><a href='#'>row 2 > link</a></td><td>b</td></tr>" > htmlrows+="<tr><td>row 3 desc</td><td><a href='#'>row 2 > link</a></td><td>c</td></tr>" >
Why can't you instead do something like this: tablerows = [] for i in something: tablerows.append(TR(...)) tbody = TBODY(tablerows) > htmltablehead=XML(THEAD(TR(TH('Column 1'),TH('links'),TH('column 3')))) > htmltablebody=XML(TBODY(XML(htmlrows))) > htmltable=XML(TABLE(XML(htmltablehead),XML(htmltablebody),_class="pure-table > pure-table-bordered")) > Note, when you have actual HTML helper objects (e.g., your THEAD object), there is no need to wrap them in XML() before passing them to other helper objects. Also, if for some reason you feel you really need to build the rows as raw HTML markup, then there isn't really much point in using the TBODY and TABLE helpers anyway -- they're each just a single HTML tag, which you might as well just write in raw HTML yourself. Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.