logo       

Re: Process vs Macro ?: msg#00058

Subject: Re: Process vs Macro ?
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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe