What's the difference between
MACRO foo BLOCK
...
END
and
BLOCK foo
...
END
?
Historically I've always used the latter but have come to a new shop where they seem to have always used the former, and was wondering what the difference was.
What's the difference between
MACRO foo BLOCK
...
END
and
BLOCK foo
...
END
?
Historically I've always used the latter but have come to a new shop where they seem to have always used the former, and was wondering what the difference was.
块实际上是一个MACRO
函数,每次调用时都会重新计算,并且传递的任何变量都是宏的本地变量。命名块要么是静态的,要么是通过PROCESS
or调用INCLUDE
的,其中关于变量范围的常见警告适用。
例如
MACRO foo (arg1, arg2) BLOCK;
... do something with arg1 and arg2
END;
...
Foo is a [% foo(bar,baz) %]
相对
BLOCK foo
... do something with arg1 and arg2
END;
...
Foo is a [% PROCESS foo arg1=bar arg2=baz %]
长话短说,MACRO
语法不那么冗长,特别是对于看起来和行为像函数调用的代码。