[ZPT] Re: [Zope] returning an HTML comment from ZPT

Evan Simpson evan@4-am.com
Thu, 23 May 2002 17:58:58 -0500


Fred L. Drake, Jr. wrote:
> dman writes:
>  > | <tal:comment condition="">
>  > | This code stinks, I should fix it some time ;-)
>  > | </tal:comment>
>  > 
>  > I didn't know about the "tal:comment" tag.  
> 
> Read the example carefully -- there isn't a tal:comment element
> defined by TAL; he's relying on the behavior of condition="", and
> probably made a typo and meant tal:condition="".

True, the condition="" does the work, but it's fine as written.  He's 
taking advantage of the fact that TAL will treat attributes of any tag 
in the 'tal' namespace as implicitly belonging to the namespace.  If 
your favorite tools tolerate it, you can therefore write stuff like:

<tal:setup define="getters here/lib/get_funcs">
...(much text omitted)...
<tal:widgets repeat="widget getters/widgets">
   <p>Widget #<tal:n replace="repeat/widget/number">42</tal:n>
   is called <i tal:content="widget/name">Foo</i>
</tal:widgets>
</tal:setup>

...and the made-up tag name acts as a sort of mini-comment.  It can 
certainly help at the end of a set of nested blocks to see 
"</tal:items></tal:groups></tal:sections>" instead of 
"</div></div></div>".  Also, the open and close "tal:setup" tags above 
don't appear in the rendered page, only the text between.

Cheers,

Evan @ 4-am