On 06/12/06, David Xiao <[EMAIL PROTECTED]> wrote:
>
> I am not quite understand how to generate KID template in that way.
> For example, pics = Pictures.select(orderBy='shortname') returns 5
> results, and I want the HTML code look like, 2 elements per row:
> <table>
> <tr>
> <td>result 1</td>
> <td>result 2</td>
> </tr>
> <tr>
> <td>result 3</td>
> <td>result 4</td>
> </tr>
> <tr>
> <td>result 5</td>
> <td></td>
> </tr>
> </table>
>
> How should I write .kid template code?
Well you want to send a list of tuples to your template, where each
tuple has two pictures in it. Then you just iterate through that.
Using the grouper example someone else posted, I would guess something
like this might work:
in controller:
pics = izip(*[chain(Pictures.select(orderBy=Pictures.q.shortname),
repeat('', 1))]*2)
in template:
<tr py:for="pic1, pic2 in pics">
<td>$pic1</td>
<td>$pic2</td>
</tr>
This is entirely untested but should give you an idea.
Ed
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---