[Templates] Process vs Macro ?

Randal L. Schwartz merlyn@stonehenge.com
22 Sep 2006 08:14:16 -0700


>>>>> "Evan" == Evan Carroll <evan@dealermade.com> writes:

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

BLOCK requires INCLUDE/PROCESS
MACRO creates a new function

[% BLOCK a_block; %]text with [% aparameter %] in here[% END %]
[% MACRO a_func(aparameter) BLOCK; %]text with [% aparameter %] in here[% END %]

...

via include: [% INCLUDE a_block aparameter = "fred" %]
via macro: [% a_func("fred") %]

A macro always requires a fixed number of parameters, and had to have been
already processed earlier.  A block can have defaults for parameters.  An
include can also process an entire separate file: it doesn't have to be a
block already seen.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!