[Twisted-web] Nevow - how to render sequence into 3 column table
Valentino Volonghi aka Dialtone
dialtone at divmod.com
Wed Dec 7 09:09:24 MST 2005
On Wed, Dec 07, 2005 at 04:59:58PM +0100, Paul Reznicek wrote:
> Hi all gurus,
>
> have a list of dicts like:
> data = [
> {'name' : 'Alfred'}, {'age' : 15},
> {'name' : 'Mary'}, {'age' : 17},
> {'name' : 'Bob'}, {'age' : 25},
> ...
> {'name' : 'Molly'}, {'age' : 22},
> {'name' : 'Manfred'}, {'age' : 33},
> ]
>
> !!! len(data)/3 is not a whole number !!!
>
> The result should looks like:
> <table>
> <tr>
> <td>Alfred is 15</td>
> <td>Mary is 17</td>
> <td>Bob is 25</td>
> </tr>
> ...
> <tr>
> <td>Molly is 22</td>
> <td>Manfred is 33</td>
> </tr>
> </table>
>
> Is in Nevow a way how to render this automatically using
> "pattern" for each cell ?
Sure:
<table>
<thead>
<th>
<td>Name</td>
<td>Age</td>
</th>
</thead>
<tbody n:data="data" n:render="sequence">
<tr n:pattern="item" n:render="mapping">
<td> <n:slot name="name" /> </td>
<td> <n:slot name="age" /> </td>
</tr>
</tbody>
</table>
If you really want a pattern then write a new mapping that gathers some known
patterns from the enclosed html and fills the corresponding slots.
--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20051207/9a47ae3a/attachment.pgp
More information about the Twisted-web
mailing list