htp on-line reference: USE, $


Syntax

<USE macroname (parameters ...)>
$macroname
${macroname}

Synopsis

USE will expand macros that have been previously declared with either SET or BLOCK. USE should only be used outside of other markup tags.

USE will accept additional parameters, which are "local" macros for the expanded macro. Currently, this is only valid for BLOCK macros. Macros created using SET cannot have parameters passed. (This may change in a future release.)

For example:

    <BLOCK stuff>
    <A HREF=$email>send email</A>
    </BLOCK>

    <SET morestuff=$email>

    This works: <USE stuff email="jnelson@crl.com">
    But this fails: <USE email>
    And this fails: <USE morestuff email="jnelson@crl.com">

(See below for a description of the '$' operator.) The "this works" line works because "stuff" has been declared as a block macro, and the tag is passing the "email" macro to the "stuff" macro. The "this fails" lines fail because the "email" macro is unavailable once the block macro is completely expanded, and cannot be passed to a SET macro.

Note that the "email" macro is available to other macros or included files called within the "stuff" block.

Inside a markup tag, like IMG, A (anchor), or any other standard HTML or htp tag, the '$' operator should be used. The '$' should be immediately followed by the macro name, which may or may not be surrounded by curly braces.

    <A HREF="mailto:$email">mailto hyperlink</A>
    <A HREF="http://${domain}/~${username}/">another hyperlink</A>

The use of curly braces is encouraged, since it is more robust and should never cause confusion with surrounding text. If the macro is expanded with text trailing (as in the second example), curly braces are required, else the remaining text will be interpreted as part of the macro name.

If a '$' character needs to be kept in the final output, and not interpreted as a macro name, it can be escaped by another '$' character.

If the '$' macro is the only text in the attribute's value, htp will automatically surround it with quotation marks to prevent spaces from delimiting the text as if it were additional markup attributes. If the '$' macro is surrounded by other text (as in the two examples above), quotation marks are not automatically supplied.

Note that a '$' macro can be placed anywhere in a markup tag. This is valid:

    <${tagName} ${attrName}=${attrValue}>


Table of Contents

htp on-line reference / http://maths.newcastle.edu.au/~rking/htp/ref/
Author: Jim Nelson / No email available
Maintainer: Robert King / robert.king@newcastle.edu.au

Copyright © 1995-96 Jim Nelson.
Permission to reproduce and distribute this hypertext document granted according to terms described in the Introduction

Last updated Fri Oct 27, 2000