Expression Tokens

CodeGen

Expression Tokens

 

Expressions are special tokens that can be used within template files in order to include or exclude a piece of code based on some condition. There are several different types of expressions that can be used in different places within a template file. For example, there are expressions that can be used in a field loop which allow you to include or exclude sections of code based on the attributes of the field that is currently being processed.

There are two types of expressions:

Multi-line expressions cause one or more lines of output code to be included or excluded, based on the evaluation of the expression, and occur when the opening and closing conditional tags appear on separate lines in a template file, and delimit one or more entire lines of template code, like this:

<IF expression>code
</IF[ expression]>

In-line expressions cause part of an output line to be included or excluded based on the evaluation of the expression, and occur when the opening and closing conditional tags appear on the same line in a template file, and delimit part of a line of template code, like this:

[code] <IF expression> code </IF[ expression]> [code]

Alternate Expression Closing Tags

In complex template files you may prefer to use an alternate format of the closing </IF> tag which includes the name of the condition. For example, if you are using an <IF INTEGER> expression you can chose to specify the closing tag as </IF INTEGER>. Doing so can help to make template files more readable.

Expression Else Clauses

Else clauses are supported in multi-line expressions, like this:

<IF expression>
code
<ELSE>
code
</IF[ expression]>

And in in-line expressions, like this:

[code] <IF expression> code <ELSE> code </IF[ expression]> [code]

Nesting Expressions

Multi-line expressions may be nested within one another. For example:

<IF expression1>
[code]
<IF expression2>
code
</IF[ expression2]>
[code]
</IF[ expression1]>

In-line expressions may be nested within multi-line expressions.

<IF expression1>
[code]
[code] <IF expression2>code</IF[ expression2]> [code]
[code]
</IF[ expression1]>

Multiple in-line expressions may be used within the same line:

[code] <IF expression1>code</IF[ expression1]> [code] <IF expression2>code</IF[ expression2]> [code]

In-line expressions may be embedded within one another:

[code] <IF expression1>[code]<IF expression2>code</IF[ expression2]></IF[ expression1]> [code]

 

 

 


Copyright © 2012  Synergex International, Inc.