Metatags allow for HTML-like tags to be defined and later inserted anywhere in documents. They are similar to macros, but much more powerful. Unlike macros, which simply expand into text and/or tags, metatags expand intelligently. In essence, htp's functionality can be extended without modifying the program.
Metatags are defined and undefined with the DEF and UNDEF tags. Please read these sections for a more technical explanation of the definition syntax.
As an example, to create a tag to combine the <B> (bold) and <I> (italic) tags:
<DEF NAME="BOLDITALIC">
<B><I>
</DEF>
<DEF NAME="/BOLDITALIC">
</I></B>
</DEF>
<BOLDITALIC>this text is bold and italic</BOLDITALIC>
This is a simple example. More sophisticated tags accept parameters. The OPTION parameter lets multiple metatag parameters be named and expanded inside the DEF block:
<DEF NAME="SHAREDIMG" OPTION="NAME ALT">
<IMG SRC="/home/sharedimages/${NAME}" ALT="${ALT}">;
</DEF>
<SHAREDIMG NAME="bubble.gif" ALT="Bubble image">
The SHAREDIMG tag is now shorthand for the HTML IMG tag, except that it will prepend a specific subdirectory to the pathname. Note that ALT text is also passed in.
The options are expanded inline as if they were SET macros. The '$' and brackets around the name indicate it is a macro and not normal text.
Passing block macros rather than set macros requires some extra work. The following demonstrates how to pass in a block macro into a metatag:
<DEF NAME="DROPTEXT" OPTION="TEXT">
<HR>
<H2 ALIGN=CENTER>
<USE ${TEXT}>
</H2>
<HR>
</DEF>
<BLOCK bigText>
This text is larger, centered, and surrounded by separators.
</BLOCK>
<DROPTEXT TEXT=bigText>
The key is the "<USE ${TEXT}>" line. Rather than simply reference the macro name normally (as USE would normally require), it is treated as a macro name in of itself. In essence, the parameter is a pointer to a pointer, and must be dereferenced twice.
However, this means that the DROPTEXT parameter must always be a block macro, or at least a SET macro defined prior to invoking the metatag. A simple way around this problem is to have two different options, one for set macros and the other for block:
<DEF NAME="DROPTEXT" OPTION="TEXT BLOCK">
<HR>
<H2 ALIGN=CENTER>
<IF TEXT>
<USE TEXT>
<ELSE>
<USE ${BLOCK}>
</H2>
<HR>
</DEF>
<DROPTEXT TEXT="Drop text">
<BLOCK bigText>
This text is larger, centered, and surrounded by separators.
</BLOCK>
<DROPTEXT BLOCK=bigText>
To make defined metatags available to all htp documents, place them in a common include file, or more convieniently, in the htp default file.
htp on-line reference / http://www.ens.gu.edu.au/robertk/htp/ref/
Copyright © 1995-96 Jim Nelson.
Permission to reproduce and distribute this hypertext document granted
according to terms described in the Introduction
Last updated Mon Sep 23, 1996