Developer Documentation
RAVL, Recognition And Vision Library
USER HOME PAGE CLASS LIST CONTENTS
Ravl - OS - Text Processing - Templates


Template Language

The following is a brief description of the template language implemented in the TemplateFileC and TemplateComplexC classes. These are the basic commands provided for all templates. It is easy to add more commands which are appropriate for a particular application.

Simple Templates

The template file is copied character for character to the output file, including cariage returns etc, except in where the following strings are found. This template syntax is implemented in TemplateFileC.
$(x) Substitute variable 'x' into file.
$$( '$$(' becomes '$(' in the output. '$' followed by any other text is copied to the output.
Note: Extra close brackets ')' will be send to the output as normal.

Complex Templates

The TemplateComplexC file uses a similar syntax, but interprets more complex variables, of the form: $(x:a) Execute command 'x' with parameter 'a'
Note: expand in the following context means substitute all variables in it, and make it value of the command.

Commands

Commands recognised by the basic interpreter are as follows:
$(//:a) Discard 'a', as a comment
$(set:a=b) Assign the expanded value of 'b' to variable a
$(for:a:b:c) For each item in list 'b', separated by the delimiters in string 'a'. Substitute %arg% into 'c' and expand it. If a number of deliminators are found in a row, they are treated as a single deliminator. i.e. two spaces in a row is treated as one space.
$(if:a:b) If condition 'a' is true, expand 'b'. For a description of conditions see below.
$(ifset:a) If variable 'a' is set, then expand 'b'.
$(else:a) If the last condition failed, expand 'a'
$(include:a) Include the file 'a' as if where part of this file
$(sub:a) Expand 'a' in new environment, with no variables set. The values of any variables set within this environment are discarded on completion.
$(subc:a) Expand 'a' in new enviroment, with a copy of current variables. The values of any variables set or changed within this enviroment are discarded on completion.
$(subst:a:b:c) Expand 'c' and subitute all instances of string 'a' with string 'b'. Then output it.
$(define:a:b) Define a new macro called 'a', upon execution substitute the macro parameter for %arg% in 'b' and expand it. Macros can then be executed as any other command. Caution, standard commands may be overriden with this
$(htmlsafe:a) Make appropriate substitutions to an expanded version of 'a' so it will read properly in a html browser.
$(uppercase:a) Expand 'a', and make it all upper case.
$(lowercase:a) Expand 'a', and make it all lower case.
$(before:a:b) Expand 'b', and make return all text before 'a'. Return the whole string if 'a' is not found.
$(after:a:b) Expand 'b', and make return all text after 'a'. Return the whole string if 'a' is not found.
$(silent:a) Expand 'a', but discard the output. This maybe user to comment the setup of variables, without sending the comments to the output file.
$(FilePattern:a) Special keyword, ignored. (well kinda)
$(FileObject:a) Special keyword, ignored. (well kinda)

Conditions

Here are the conditions understood by if command:
a = b If 'a' equals 'b'
a != b If 'a' does not equal 'b'
x & y If x and y are true, where 'x' and 'y' are conditions.
x | y If x or y are true, where 'x' and 'y' are conditions.
& always has precident over |, making the condition a min term. The condition may include fix strings or variables, which are proceeded by a '$'. e.g. $a=b If the value of variable 'a' equals 'b'
Charles Galambos
Last modified: Mon Jul 16 13:27:31 BST 2001
Documentation by CxxDoc: Tue Aug 13 10:00:48 2002