Embedded template commands

Top  Previous  Next

The Document Handler recognises three commands that can be embedded in the template. These commands follow the syntax rules for Server Side Include commands. A Server Side Include command starts with the characters left angle bracket, exclamation mark, hyphen, hyphen, number sign followed by the command and it is terminated with the characters hyphen, hyphen, right angle bracket. For example:

    <!--#command -->

The three commands that are supported are #set, #echo and #include.

#set

The #set command is used to set the values of symbols and is useful for setting up default values for symbols. The #set command in the template will be ignored if the symbol has already been given a value using the DOCUMENT SET command. If a previous #set command has been used to assign a value to the symbol, the value will be overridden. A symbol which has been assigned a value using the DOCUMENT SET command can only be changed by issuing another DOCUMENT SET command.

#echo

The #echo command identifies a symbol that must be substituted when the template is inserted into the document. The string containing the #echo command will be completely replaced by the value associated with the symbol. If no symbol has been defined with that name, the #echo command will remain in the output data.

An alternative method to using the #echo command is to specify the symbol name, preceding it with an ampersand and terminating it with a semicolon. If we set a symbol called ASYM and give it a value of 'sample', the following two templates will give the same result after substitution.

Template 1:

This is an example template.
<!--#set var=ASYM value='sample'-->
This is a <!--#echo var=ASYM--> symbol.

Template 2:

This is an example template.
<!--#set var=ASYM value='sample'-->
This is a &ASYM; symbol.

Result of substitution:

This is an example template.
This is a sample symbol.

#include

The #include command allows a template to be embedded within another template. Up to 32 levels of embedding are allowed.

For example:

<!--#include template=templatename-->

where templatename is the name of the template (the 48 byte name) defined in the doctemplate definition. The template name can also be enclosed in double quotes.