Evan,
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?
One thing I don't see that anyone's mentioned is that when you PROCESS/INCLUDE a template that has MACROs and named
BLOCKs _in_ it, you would call those differently:
File templates/myfuncs.tt2:
[% BLOCK thing1 %]
[%# stuff %]
[% END %]
[% MACRO thing2() BLOCK %]
[%# stuff %]
[% END %]
File templates/mytempl.tt2:
[% PROCESS myfuncs.tt2 %]
[% PROCESS myfuncs.tt2/thing1 %]
[% thing2() %]
Also, a BLOCK produces output. A MACRO returns a value. So you can also do
this:
[% 'something' IF thing2() == 'whatever' %]
which wouldn't work with a BLOCK.
For both of these reasons, I hardly ever use BLOCKs unless they're going to a) only going to be called from the current
template, and b) always going to produce output directly to the user.
-- Buddy
|