Chapter 9 Generation Reference Guide (GTL)


Defining conditional blocks

Conditional blocks can be used to specify different templates based on the value of a variable.

{syntax 1}: '[' <variable> '?' <simple-template> [':' <simple-template>] ']'

{syntax 2}: '[' <text> <variable> <text> ']'

Syntax 1 is similar to C and Java ternary expressions. If the value of the variable is false, null, or the null string, the second template, if specified, is evaluated, otherwise the first one is evaluated.

Syntax 2 has a slightly different meaning. The simple template <text><variable><text> is translated if, and only if the value of the variable is not the null string.

Example: an attribute declaration in Java:

%Visibility% %DataType% %Code% [= %InitialValue%]

 


Copyright (C) 2005. Sybase Inc. All rights reserved.