[PHPTAL] metal:define-slot, fill-slot, and macros
Eric Brown
cephelo at gmail.com
Wed Nov 2 16:00:03 CET 2005
Ah, I figured it had something to do with naming conflicts. If you
have a todo list, could you add this to the manual? It says that slots
are typically used with macros, but doesn't offer a complete example
like your message did.
On 11/2/05, Laurent Bedubourg <lbedubourg at motion-twin.com> wrote:
> On Tue, 2005-11-01 at 21:48 -0500, Eric Brown wrote:
> > Based on the PHPTAL manual, I should be able to do the following:
> >
> > --- file.htm ---
> > <div metal:fill-slot="content">
> > Today... .. ...
> > </div>
> >
> > <html metal:use-macro="base.htm/column" />
> >
> > --- base.htm ---
> > <div metal:define-macro="column">
> > <div metal:define-slot="content">
> > Content will come here
> > </div>
> > </div>
> >
> > right? As far as I know, this worked fine in a prior version (or
> > something similar worked). Now the code that calls the macro in the
> > generated file.htm file is surrounded by:
> >
> > $ctx->pushSlots(); and $ctx->popSlots();
> >
> > which effectively clear $ctx->_slots for the macro inclusion and
> > restore it after the macro is done. Doesn't that defeat the purpose of
> > slots across multiple templates?
> >
> > If I remove (or comment out) the functionality of Context::pushSlots()
> > and Context::popSlots() it works as I expect.
> >
> > I generally try to abstain from modifying good source packages -- is
> > there a reason it behaves this way, or am I doing something wrong?
> >
>
> It behaves this way to avoid slot conflicts in macros calling macros
> with same slot names (and this kind of ugly things).
>
> The right macro call syntax is :
>
> <html metal:use-macro="base.htm/column">
> <div metal:fill-slot="content">
> Today... .. ...
> </div>
> </html>
>
> Best regards
> Laurent
>
>
More information about the PHPTAL
mailing list