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

Attachment: pgpPQCigNwsJZ.pgp
Description: PGP signature

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to