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

Jeffrey P Shell jeffrey@cuemedia.com
Wed, 01 May 2002 17:11:37 -0600


On 5/1/02 4:14 AM, "Jon Edwards" <jon@pcgs.freeserve.co.uk> wrote:

> Chris wrote :
>> 
>> ...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">
> 
> Chris (or anyone), how do editors like Dreamweaver handle this - do they
> choke on unrecognised <tal> tags? In my quest for ZPT-Zen I'm trying to tidy
> up and improve my style, and as you say, this does seem much neater than
> lots of nested divs and spans.

Dreamweaver and GoLive *usually* leave them alone.  But sometimes, they
(rightly) get confused in WYSIWYG mode and turn what's meant to be a single
element into many - one for each "line" basically.  So, you still have to be
careful.  Basically, the tools don't know how "local" to make a big block
tag, whether it's a DIV or something else.  So you can end up with this:

<div metal:fill-slot="main">I slept a lot this weekend</div>

<div metal:fill-slot="main">I should stop doing that</div>

When you meant to have just the one <div metal:fill...> surrounding the
whole thing.  :/  I don't recall if I've had the same behaviour happen when
I've used the metal: namespace directly as a tag, but I think it has
happened.

Care just has to be taken.  It's usually actions that cause serious
paragraph reformatting (splitting a single paragraph into two, for example)
that can start causing mayhem.  Fortunately Dreamweaver and GoLive both
offer a split source/WYSIWYG mode and quick tag editing.  And GoLive's
outline editing mode is great for working on TAL heavy documents, especially
once the design has settled down.

> On a slight tangent, when you do a "define" in ZPT does it work similarly to
> a <dtml-with> in DTML? i.e. puts the thing you have defined into the
> namespace until the closing tag? So, if you have an expensive call, you're
> only doing it once, then using the results from the namespace, as long as
> you're within the "define" tags? (Does that question make any sense, it's
> hard to explain? ;-)

Yes.  Unless you define a global:
 <...tal:define="global bob here/rockabilly/uncle">.

-- 
Jeffrey P Shell 
www.cuemedia.com