I still do not understand when and why to use slots,
I always use macro.
Can anyone show me a meaningful and useful example demonstrating when slots
are better then macro?
Regards,
Anton Andriyevskyy
Business Automation Web Development
___
PHPTAL
siteheader.xml template file:
div metal:define-macro=siteheader id=header
tal:block metal:define-slot=debug/
pSome example text/p
img src=stuff.png alt=stuff/
/div
Actual file rendered:
tal:block metal:use-macro=siteheader.xml/siteheader
p metal:fill-slot=debug class=debug
Ok, Marco, so actually we are still continuing to use macro, but we make
them more dynamic
by defining slots, correct?
Then still I have question how it's better then defining macro (instead of
fill-slot) and call it
with variable macro name inside template?
Any thoughts?
Anton Andriyevskyy
Suppose that you wrote a complex template...
It has a header, footer, sidebars, h1, site logo...
Let's say you wish to have just 1 javascript or css added to your template
when visiting any page that relates, let's say, the user profile.
Supposingthat you're using some standard MVC stack you'd
The big advantage I personally see in this way of developing is that your
template
doesn't need to be aware of every variable that could be injected in it.
... but as for me this adds 2 disadvantages:
1) every secondary template that uses that main template must be aware of
its slots;
taking
1) I usually don't have secundary templates. Or at least, this happens
rarely, like when differentiating emails from website xhtml. I prefer having
small and clean templates that use the smallest possible number of
variables. Supposing I write a xhtml wrapper template that accepts some
content and
The head/ replacement in the template above is obviously an overkill as it
is a required xhtml element, but I hope it renders the idea of being able to
replace stuff at precise spots :)
Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com
On 11 July 2011 10:37, Marco Pivetta
Ok, first at all you do have secondary templates in your approach - just to
make clear how I used terms:
* your primary template is the one with slots
* your secondary template is the one which uses primary one and replaces
*p.s. please do not argue on usage of terms, lets just assume what is
Didn't really unserstand where with using macro your macro must not know
anything about environment goes:
If you currently work with switching template behavior then your template
knows about environment (variables passed in). They ARE the environment :|
With macros I slice my template logic in
On 07/11/2011 01:45 PM, Anton Andriyevskyy wrote:
yes, I'm also interested in what others will say.
I quite don't understand why you compare macros against slots. Slots are
part of macros. It allows customisation of a macro.
I use macros/slots the following way:
- a main page template with
We use slots as a way of implementing decorators in our templates.
Often our designers use a similar wrapper of HTML around various
pieces of content and we want them to be reusable. There's actually
two separate ways we could accomplish this feat.
First, using only macros, we could simply pass
On 07/11/11 13:33, Darrell Hamilton wrote:
We use slots as a way of implementing decorators in our templates.
Often our designers use a similar wrapper of HTML around various
pieces of content and we want them to be reusable. There's actually
two separate ways we could accomplish this feat.
Sorry about that, just like this example alot.
On 07/11/11 21:48, Levi Stanley wrote:
On 07/11/11 13:33, Darrell Hamilton wrote:
We use slots as a way of implementing decorators in our templates.
Often our designers use a similar wrapper of HTML around various
pieces of content and we want
13 matches
Mail list logo