[Zope] My first question.

J. Cameron Cooper jccooper at jcameroncooper.com
Wed Dec 3 22:37:22 EST 2003


Goldthwaite, Joe wrote:

>Son of a..., that worked!  I don't understand it.
>
> <b tal:omit-tag="python:item.Flags!='B'" tal:content="item/desc" />
>
>Does this rely on the " />" at the end to close the B tag or does the tal
>interpreter close it automatically?
>  
>
Little of both. When you ask the interpreter to provide the content of a 
self-closed tag, it'll go ahead and make it a regular tag set. But the 
self-closing is used to validate that it's valid XML, like ZPT wants.

You can also write this as::
 
  <b tal:omit-tag="python:item.Flags!='B'" tal:content="item/desc">An 
item description</b>

which is better because it makes sense when it's rendered without being 
interpreted (as in an HTML editor.) Even if you don't use one, it plans 
to think ahead.

Remember that ZPT actually understands XML, unlike, well, any other 
templating language. You'll want to work in full valid XML statements, 
rather than the arbitrary character stream that DTML and everything else 
allow (and encourage.) This is why METAL macros fit ZPT better, and not 
SSI-like headers and footers: everything is always a valid XML document.

          --jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."





More information about the Zope mailing list