[ZPT] Making TAL span across XHTML tags (long)

Martijn Pieters mj@digicool.com
Fri, 20 Apr 2001 10:58:24 +0200


On Fri, Apr 20, 2001 at 01:24:09AM -0700, Butch Landingin wrote:
> This is fine so far (I told you this will be a long message ;^))
> However, if I want each iteration (i.e. loop over each article) 
> to generate two rows so that it produces something like this:
> 
> <table>
>   <tr class="article_title"> 
>      <td>
>          Article 1 title 
>      </td>
>   </tr>
>   <tr class="article_body"> 
>      <td>
>          Article 1 body blah blah 
>      </td>
>   </tr>
>   <tr class="article_title"> 
>      <td>
>         Article 2 title 
>      </td>
>   </tr>
>   <tr class="article_body"> 
>      <td>
>         Article 2 body blah blah 
>      </td>
>   </tr>
> </table>

Hi Butch,

Note that HTML 4.0 defines a <TBODY> element, which you can use as many
times as you like. It is ment to (1) set apart the body of a table from
it's header and footer rows (so a browser can scroll it independantly, or
reuse header and footer when printing on multiple pages), and (2) groups
rows for easy manipulation and application of common CSS attributes.

Thus, you can create your example like this:

 <table>
   <tbody tal:loop="...">
      <tr class="article_title"> 
         <td tal:content="...">
             Article 1 title 
         </td>
      </tr>
      <tr class="article_body"> 
         <td tal:content="...">
             Article 1 body blah blah 
         </td>
      </tr>
   </tbody>
   <tbody tal:replace="nothing">
      <tr class="article_title"> 
         <td>
            Article 2 title 
         </td>
      </tr>
      <tr class="article_body"> 
         <td>
            Article 2 body blah blah 
         </td>
      </tr>
   </tbody>
 </table>

The rendered <tbody> elements together form the whole table body, as far
as the browser is concerned.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------