[Petal] Various things

Evan Simpson evan at 4-am.com
Wed Jul 9 10:15:44 BST 2003


Fergal Daly wrote:
> On Wednesday 09 July 2003 13:17, Jean-Michel Hiver wrote:
>>I must confess that I do not fully understand METAL macros. They seem to
>>be some kind of includes inside-out. Apparently the advantage is that it
>>is more WYSIWYG-compatible that an include statement.
> 
> No clue, I also found them very strange, I think I worked through an example 
> once and it made sense but it soon leaked out of my brain again.

Perhaps the best illustration of the idea behind METAL macros is to 
contrast them with includes from a designer's point of view.

Suppose you have a chunk of HTML representing a navigation sidebar that 
you plan to reuse all over a site.  The site uses CSS heavily.  If you 
open an include file containing the sidebar, you'll see a mash of text 
and links, but nothing like what the sidebar will look like on the site, 
because the include file doesn't have the proper stylesheet information 
or page context to properly render it.  Open one of the pages that use 
this include file, and there will be a little icon where the navigation 
bar should be, if anything.  This may well distort the layout of the 
rest of the page, making it harder to design.

If the site is built with METAL macros instead, the sidebar macro lives 
in a page that has all of the necessary stylesheet and HTML context to 
render it properly.  Each of the pages that use the macro have an 
up-to-date copy of the macro embedded in them, so their layout is correct.

Naturally, if the only people who touch your site's source use emacs or 
some other non-WYSIWYG editor, these points are moot.  Also, the 
expansion of METAL macros where they are used is much easier in Zope 
than in a filesystem-based implementation such as Petal, since Zope 
dynamically expands macros whenever the source of a template is requested.

Once upon a time, we had an ambitious plan for macros that would allow 
for editing them in places that they were used, and propagating the 
edits back to the macro definition.  It proved a bit too complicated.

Cheers,

Evan @ 4-am




More information about the Petal mailing list