[Petal] [IDEA] Hash with params

Jean-Michel Hiver jhiver at mkdoc.com
Thu Sep 11 10:08:00 BST 2003


On Thu, 2003-09-11 at 03:01, Evan Simpson wrote:
> Jean-Michel Hiver wrote:
> > Gotcha! Brilliant idea. Now that I understand what it is about, I think
> > it'll be rather easy to implement with Petal. You'll be able to stack
> > prefixes too, which is a Petal feature suggested by William some time
> > ago.
> 
> Thanks, but I'm not sure what you mean by "stacking".  It's certainly 
> valid to write something like "x/var:y/item:0/key:fred", if that's what 
> you're getting at.

I was meaning for example x/prefix1:prefix2:stuff


> Except that macro names live in their own namespaces, completely 
> separate from variables, and slot names are merely markers for nodes. 
> The abstract idea is that the template and macros are combined into a 
> notional intermedate template, which is then executed.

OK.


> That's not how we implement it, of course.

?


> > define-macro serves as an indentifier. Which makes me think: Why not use
> > a more standard syntax for XML / HTML fragments in URLs when you do
> > includes? (i.e. use-macro="my/file.xml#mymacro").
> 
> Because we tried to use as little syntax as possible, and 
> ".../macros/mymacro" is very natural in a Zope context.  YMMV, of course.

Mhhh. I don't know about this. When I implement METAL I might break the
specification regarding this syntax. Mind you it wouldn't be the first
time :)


> > If / When this is implemented with Petal, the following macro should be
> > possible:
> > 
> > <ul tal:define="child self/root">
> >   <li metal:define-macro="sitemap_li">
> >     <a
> >       href="#"
> >       hreflang="en"
> >       lang="en"
> >       xml:lang="en"
> >       tal:attributes="href child/Full_Path;
> >                       hreflang child/Lang;
> >                       lang child/Lang;
> >                       xml:lang child/Lang"
> >       tal:content="child/Title"
> >     >Child Document Title</a>
> >     <ul
> >       petal:define="children child/Children"
> >       petal:condition="children"
> >       petal:repeat="child children"
> >     >
> >       <li metal:use-macro="#sitemap_li" />
> >     </ul>
> >   </li>
> > </ul>
> 
> Yipe!  That looks infinitely recursive to me.  Did you really mean to 
> use the macro inside its own definition?

Well, when building any kind of include mechanism you have two options:

a/ Expand all the includes and then run the template
b/ Expand the includes at run-time

Petal uses the latter. So if METAL was built upon Petal includes, this
example above would work.

Cheers,
Jean-Michel.


More information about the Petal mailing list