Content-type: text/html Macro Tag

Home
WebGroove is no longer supported. These docs are reference only.


Macro Tag
The macro tag defines custom HTML-like tags for use with the Compiler. You can create macros that use tokens in conjunction with HTML, text, Perl, XML, PHP, VBScript, JavaScript, and Agent code. Macros are the preferred method of providing extensions to WebGroove® Script and can produce some really robust static and interactive features, all nicely wrapped into simple tags.

Syntax
Used as a tag pair when defining a macro. The macro name must be the first attribute. You can specify one or more user-defined attribute default values by placing them after your macro name. If using the default attribute to override defaults, macro is used as a single (non-pair) tag.

Defining a Macro
Macros work a like a form letter template in a mail-merge application. To use attributes in a macro, surround the attribute name with curly braces (e.g. {font}). If the macro is a tag-pair, the Compiler automatically defines an attribute called {body}. Always reference these attributes in lowercase. When the macros are used, attribute names can be in any case, but they will always be lowercase when accessed within a macro definition. Yes, you can use ifdef to evaluate an attribute at time of use. You can use the "{attrib}" references as you would any other token within the scope of the macro definition.

<macro normal face="Arial, Swiss" size=-1>
<font face="{face}" size={size}>
<ifdef {bold}><b><i></ifdef>
{body}
<ifdef {bold}></i></b></ifdef>
</font>
</macro>


<macro mailto to="webmaster@mydomain.com" name={to} single packed>
<b><a href="mailto:{to}">{name}</a></b>
</macro>


Using a Macro
To use a defined macro, simply type it like it was an HTML tag. You can pass optional parameters and place some text between a tag pair.

<normal bold>
I want this text to be normal.
Notice I passed a value for the
bareword "bold" which the macro
uses to determine if I want this
this block to be bold and italic.
</normal>


<mailto to="info@mydomain.com">

<mailto to="bob@mydomain.com" name="Bob Wilson">

Attributes
single This macro will be a single tag, not a tag pair.
default You can override one or more defaults for a previously-defined macro by including this bareword and the defualt attribute values you want changed. Include an attribute name as a bareword to undefine the default.
packed Instructs the compiler to "crush" linefeeds into spaces. Mildly useful in some situations.


Notes
Any token generated by the compiler can be accessed within a macro and other macros called within the scope of that instance. When in doubt with scoping, "pass in" attributes to nested macros or use different attribute names. Most times the Compiler does what you'd expect.

Warning
If you want an endless compile, refer to a macro within its own definition. Because of this, it is difficult to override standard HTML tags like form, input and title. Be careful out there.

More
Be careful when replacing HTML tags
Making single-line custom tags

See Also
Compiler Tokens
Init Tag
Macro Library

Up To
Compiler Tags
Complete Tag Reference


WebGroove® is a registered trademark of Creativision Publishing Corporation