<blocklet>
Blocks of Macro Language code defined with <blocklet>
allow for
parameterized variables and block-control forms without defining a named block.
Description
The <blocklet>
form is similar to <block>
in that
the contents of a <blocklet>
are expanded and executed (after any
parameter substitutions). Similarly, block-control forms such as <for>
and <quote>
may be used in a <blocklet>
in the same
way they are used in a <block>
.
However, a <blocklet>
is unnamed; no name
attribute is
provided. Since the block cannot be referenced, the <blocklet>
cannot be
called using <call>
or <insert>
.
Syntax
<blocklet "[USER_DEFINED_VAR_1]="[VALUE_1]" ...
[USER_DEFINED_VAR_N]="[VALUE_N]">
<note>Macro Language code with parameterized variables goes here</note>
</blocklet>
Attributes
[USER_DEFINED_VAR_x]
- Accepts a string that will act as a user-defined variable. The variable name must
begin with a lowercase alphabetic character and consist only of lowercase alphanumeric
characters, digits, and/or underscores.
The block element may include any number of additional attributes, which may be used as parameters in the Macro Language code contained within the element. The value of a user-defined variable (e.g.,
my_var
) is substituted wherever a scalar expression containing a reference to it (e.g.,{@my_var}
) appears within the block element.
Example
The following example an example of including Macro Language code inside a
<blocklet>
. The Macro Language code contains a block-control form
(<if>
) as well as variable substitution (e.g.,
{@include}
, {@foo}
). However, since it is not being
called externally by any code, it does not need to have a name; therefore, it can be in a
<blocklet>
instead of a <block>
.
<blocklet foo="" include="1"> <set> <foo> a,b,c; <if test="{@include}"> 1,2,3; </if> </foo> </set> <quote t="{@foo}"> <table>{@t} </table> </quote> </blocklet>