tags:

views:

112

answers:

1

I need to generate a HTML using a Genshi template. The Html is, basicaly a very long html with tables. The data comes in a simple CSV, so, i read it with python, i put it into a list[] and then i call the template and send the variable (the list)

Actually i solved it by doing something like this in the template:

<html>
<?python>
    for i in t:
       for e in tp[i]:
           print "<SOME_HTML_TAGS>"
</?>
</html>

But, the idea is to use the Genshi funcions (such as loops, etc)

I read the manual, and I see that a simple for is done like this:

<li py:for="fruit in fruits">      
I like ${fruit}s                   
</li>

But, how do i do a loop inside a loop (nested for loops)???

+2  A: 
<table>
<tr py:for="i in t">      
<td py:for="e in tp[i]">
${e}s
</td>
</tr>
</table>
nosklo
And, what if I need to generate n tables? I mean, one loop is for the content of the table, the other for the table itself.
mRt
This, works???<table py:for"i in t"> <td py:for="e in tp[i]">${e}s</td></tr></table>
mRt
@mRt: your example isn't valid xml - you didn't open <tr>.
nosklo