[ZPT] Should tal:content keep surrounding tags?

Jim Fulton jim@digicool.com
Fri, 01 Jun 2001 12:59:05 -0400


I got a chance to use ZPT and Adobe Go-Live recently and am
*very* happy with the experience. 

I did come across a minor, but perhaps significant
problem.  I was messing around with formatting in table cells
and ended up with cells like:

  <td><font color="white"><font size="+1">splat</font></font></td>

I needed to put the tal:content attribute on the inner most font
tag, which didn't feel quite right. I then made the text italic 
and ended up with:

  <td><font color="white"><font size="+1"
    tal:content="here/splat"><i>splat</i></font></font></td>

Now, obviously, the <i> tag will have no effect on the
rendered page, as it is part of the text that will be
replaced by the tal:content directive. 

This problem introduces an unwanted and subtle dependency
between the presentation and the dynamic logic, which is pretty
bad.

I can think of two solutions and am interested in what ideas others
may have:

  A. Define tal:content so that it includes "surrounding" tags.
     That is, if the marked up tag has one child that is
     an element, then apply the content-replacement alogorithm
     recursively to the element as if the tal:content attribute
     was on the element. In the application of the above rule, maybe
     apply it if there are three children, which are a text node 
     containing only whitespace characters, an element, and a text node 
     containing only whitespace characters.

  B. Define a new tal attribute/statement with the above semantics.

Either of these would have allowed me to put the tal attribute
on the td element:

  <td tal:content="here/splat"><font color="white"><font size="+1"
   ><i>splat</i></font></font></td>

which would allow dynamic data insertion without losing added
presentation tags.

Jim
   

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org