Conditional closing </tr> tag for TAL

"Takahashi, Michael" <[email protected]> Mon, 20 Jun 2005 08:59:50 -0700
Newsgroups gmane.comp.web.zope.page-templates
Message-ID <743F9CE1E563EA41B441C9330D70FA1D313BFA@webmail>
Hi Guys,

 

I'm developing a dynamic ZPT that builds a table dynamically from an
external database. I'd like to create a table row with at most two
columns.  The condition is that if there is an odd number of data, the
last table row will only contain one <td>.  If there is an even number
of data, then the last table row will contain two <td>'s.  Sounds pretty
simple right?  Just create a condition on the closing </tr> tag....well
as I have found out, it's not so simple in TAL.

 

For example:

 

4 items of data will create two table rows

 

<tr>

   <td></td>

   <td></td>

</tr>

<tr>

   <td></td>

   <td></td>

</tr>

 

5 items of data will create 3 table rows

 

<tr>

   <td></td>

   <td></td>

</tr>

<tr>

   <td></td>

   <td></td>

</tr>

<tr>

   <td></td>

</tr>

 

 

In TAL, you cannot create a condition on a closing tag because Zope will
treat it as invalid HTML since the opening <tr> tag will not have a
closing </tr> tag.  This really makes simple tasks such as mine very
complex now.

 

Ideally, I would like TAL to function somewhat like so without Zope
complaining:

 

<tal:tr condition="logic goes here"></tr></tal:tr> 

 

 

Any suggestions?

 

Thanks,

 

Mike

 

 

 

Mike Takahashi
Web Developer * TEC@OID

UCLA Office of Instructional Development
mtakahashi (at) oid.ucla.edu
310.794.9371

_______________________________________________
ZPT mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zpt