[Twisted-web] Nevow - how to render sequence into 3 column table
Paul Reznicek
maillists at ivsn.com
Wed Dec 7 09:23:15 MST 2005
Valentino Volonghi aka Dialtone wrote:
>> 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.
Hi Valentino,
thank you for quick response, but this is not the target! Your recipe will results in:
| name | age |
| name | age |
...
table, but I'm looking for a table result like:
| name IS age | name IS age | name IS age |
...
| name IS age | name IS age | <empty> |
The trick should be to get more (i.e. 3) data-sets into 1 row !
Is there a way?
Paul
More information about the Twisted-web
mailing list