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:

====================================
[% 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="red",fruit="apple") %]
# Nesting cmd_x inside cmd_y
[% cmd_y(color="opaque",fruit="[" _ cmd_x(color="yellow",fruit="banana")
_ "]") %]
=====================================

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="opaque",fruit="[" _ cmd_z(color="yellow",fruit="banana")
_ "]") %]

What I would get is the same thing as if I typed in:

[% cmd_y(color="opaque",fruit="[]") %]

**************************************

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="red", fruit="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="opaque",fruit="[" _ cmd_x(color="yellow",fruit="banana")
_ "]") %]

as:

[% PROCESS cmd_y color="opaque", fruit="[" _ (PROCESS cmd_x
color="yellow", fruit="banana") _ "]") %]
or:
[% PROCESS cmd_y color="opaque", fruit="[" _ (cmd_x color="yellow",
fruit="banana") _ "]") %]
or:
[% PROCESS cmd_y color="opaque", fruit="[" _ cmd_x(color="yellow",
fruit="banana") _ "]") %]

Thanks for your help,
Mark

Reply via email to