[Templates] Checking for undefined BLOCKs or MACROs
Mark Anthony
manthony1@iname.com
Mon, 30 Apr 2007 15:47:07 -0500
This is a multi-part message in MIME format.
--_----------=_1177966027163500
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="iso-8859-1"
Hi,
This is a followup to a previous question about detecting undefined
MACROs.
So I found out that I can do something similar with MACROs just by using
BLOCKs and get a similar effect, but BLOCKs will abort if undefined.
Great! but now I can't seem to nest with it.
The original problem was:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
[% MACRO cmd_x BLOCK %]
[%
# Some checking of local variables
%]
cmd_a1 [% color %] ...
cmd_a2 [% fruit %] ...
[%END%]
[%MACRO cmd_y BLOCK %]
cmd_b1 [% fruit %] ...
cmd_b2 [% color %] ...
[%END%]
# Using the macros ...
[% cmd_x(color=3D"red",fruit=3D"apple") %]
# Nesting cmd_x inside cmd_y
[% cmd_y(color=3D"opaque",fruit=3D"[" _ cmd_x(color=3D"yellow",fruit=3D"ban=
ana")
_ "]") %]
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
If I mistyped "cmd_x" or "cmd_y" while using them, I wouldn't get any
warnings or errors (would be nice if it's an error). In other words, if
the last line in the previous example were:
[% cmd_y(color=3D"opaque",fruit=3D"[" _ cmd_z(color=3D"yellow",fruit=3D"ban=
ana")
_ "]") %]
What I would get is the same thing as if I typed in:
[% cmd_y(color=3D"opaque",fruit=3D"[]") %]
**************************************
Now if I declared these as named-blocks instead of macros, I'd get a
error if I do something like:
# Mistyped cmd_x as cmd_z
[% PROCESS cmd_z color=3D"red", fruit=3D"apple" %]
But now I don't know how to get nested calls to work. For example, would
I write the original line:
[% cmd_y(color=3D"opaque",fruit=3D"[" _ cmd_x(color=3D"yellow",fruit=3D"ban=
ana")
_ "]") %]
as:
[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ (PROCESS cmd_x
color=3D"yellow", fruit=3D"banana") _ "]") %]
or:
[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ (cmd_x color=3D"yellow",
fruit=3D"banana") _ "]") %]
or:
[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ cmd_x(color=3D"yellow",
fruit=3D"banana") _ "]") %]
Thanks for your help,
Mark
--_----------=_1177966027163500
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="iso-8859-1"
Hi,<br><br>This is a followup to a previous question about detecting undefi=
ned MACROs.<br><br>So I found out that I can do something similar with MACR=
Os just by using BLOCKs and get a similar effect, but BLOCKs will abort if =
undefined. Great! but now I can't seem to nest with it.<br><br>The original=
problem was:<br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>[% MACRO cmd_x BL=
OCK %]<br>[%<br># Some checking of local variables<br>%]<br>cmd_a1 [% color=
%] ...<br>cmd_a2 [% fruit %] ...<br>[%END%]<br><br>[%MACRO cmd_y BLOCK %]<=
br>cmd_b1 [% fruit %] ...<br>cmd_b2 [% color %] ...<br>[%END%]<br><br># Usi=
ng the macros ...<br>[% cmd_x(color=3D"red",fruit=3D"apple") %]<br># Nestin=
g cmd_x inside cmd_y<br>[% cmd_y(color=3D"opaque",fruit=3D"[" _ cmd_x(color=
=3D"yellow",fruit=3D"banana") _ "]") %]<br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D<br><br>If I mistyped "cmd_x" or "cmd_y" while using them, I wouldn't=
get any warnings or errors (would be nice if it's an error). In other word=
s, if the last line in the previous example were:<br><br>[% cmd_y(color=3D"=
opaque",fruit=3D"[" _ cmd_z(color=3D"yellow",fruit=3D"banana") _ "]") %]<br>
<br>What I would get is the same thing as if I typed in:<br><br>[% cmd_y(co=
lor=3D"opaque",fruit=3D"[]") %]<br>
<br>**************************************<br><br>Now if I declared these a=
s named-blocks instead of macros, I'd get a error if I do something like:<b=
r><br># Mistyped cmd_x as cmd_z<br>[% PROCESS cmd_z color=3D"red", fruit=3D=
"apple" %]<br>
<br>
But now I don't know how to get nested calls to work. For example, would I =
write the original line:<br><br>[% cmd_y(color=3D"opaque",fruit=3D"[" _ cmd=
_x(color=3D"yellow",fruit=3D"banana") _ "]") %]<br>
<br>
as:<br><br>[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ (PROCESS cmd_x =
color=3D"yellow", fruit=3D"banana") _ "]") %]<br>
or:<br>
[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ (cmd_x color=3D"yellow", f=
ruit=3D"banana") _ "]") %]<br>
or:<br>[% PROCESS cmd_y color=3D"opaque", fruit=3D"[" _ cmd_x(color=3D"yell=
ow", fruit=3D"banana") _ "]") %]<br>
<br>Thanks for your help,<br>Mark<br><br>
<div>
</div>
<BR>
--=20
<p>
<a href=3D"http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=3Den-mail_a_=
01" target=3D_blank>
<img alt=3D"" src=3D"http://a8-asy.a8ww.net/a8-ads/adftrview?redirectid=3De=
n-mail_i_01" border=3D"0"></a>
</p>
--_----------=_1177966027163500--