[Zope-CMF] <metal> and <tal> tag in ZPT

Chris Withers chrisw@nipltd.com
Tue, 30 Apr 2002 22:41:36 +0100


Tres Seaver wrote:
> 
> The element is actually in the METAL namespace;  that is, its name
> really is '<metal:block>', not '<metal>'.  It exists for the relatively
> rare case when macro expansion needs to be able to insert a slot into
> the middle of another element, and can't be attached to any other
> (legal) element (for instance, '<div>' is illegal inside the '<head>'
> element).

I find I use this pattern a lot...

> > I also found serveral comments in the Zope Book AdvZPT in which a <tal> tag
> > was used. Here's one of the examples:
> >
> >   <tal:formfields repeat="field python:form.get_fields()">
> >   <tal:fieldid define="fieldId python:field.getId()">
> >   <tal:m_formaterrorbyfield
> >         metal:use-macro="here/PT_macros/macros/formatErrorByField"
> >         condition="python:errorMap.has_key(fieldId)">
> >   <p class="errorMessage"
> >                tal:content="python:errorMap[fieldId].error_text"></p>
> >   </tal:m_formaterrorbyfield>
> >   </tal:fieldid>
> >   </tal:formfields>
> >
> > Is this residual syntax from an earlier form of TAL and METAL?  This seems to
> > be the case but the <tal> comments were posted very recently. Is the syntax
> > a new addition to TAL?
> >
> > Muddling through the documentation for over an hour has not made the correct
> > interpretation apparent to me. Am I missing something obvious?
> 
> I don't think I've ever used '<tal:xxx>' for anything, although it
> should be legal XML / XHTML.  Normally, I have "real" elements to hang
> the TAL off of.

...and this one. I see no reason to spew out lots of unneccessary <div>'s.

<tal:x define="x x">

...makes a nice shorthand for:

<div tal:omit-tag="" tal:define="x x">

...likewise:

<metal:x use-macro="x">

is a nice shortcut for:

<div metal:use-macro="x" tal:omit-tag="">

...cheers,

Chris