[Templates] Process vs Macro ?

Andy Wardley abw@wardley.org
Sat, 23 Sep 2006 08:05:48 +0100


Evan Carroll wrote:
> Could someone please juxtapose PROCESS w/ ARGS, vs, MACRO? I'm confused
> as to which one to use. PROCESS can operate on a named block, and send
> arguments into that block for invocation, MACRO does the same thing? Is
> the difference just semantic?

MACRO is a way of creating shortcuts to commonly used directives.

For example, if you find yourself doing something like this a lot:

   [% PROCESS product/picture
        image = 'example.jpg'
        title = 'An example product'
   %]

Then you can make it a MACRO like so:

   [% MACRO picture(image,title) PROCESS product/picture %]

Then you can use it like this:

   [% picture('example.jpg', 'An example product') %]
   [% picture('another.jpg', 'Another example product') %]

So The MACRO directive isn't a "real" directive of it's own.  It's just 
a way of making aliases to other directive to save on typing and help 
keep your markup a little cleaner.

HTH
A