Chapter 5 Customizing Generation with GTL
Conditional blocks can be used to specify different templates based on the value of a variable. Two different forms are available:
The first form is similar to C and Java ternary expressions. The first template is evaluated, unless the value of the variable is false, null, or the null string, in which case, the second, optional, template, is evaluated:
[
variable?
simple-template[:
simple-template]]
The second form syntax is translated only if the value of the variable is not the null string:
[
text
variable
text]
Example: an attribute declaration in Java:
%Visibility% %DataType% %Code% [= %InitialValue%]
Copyright (C) 2008. Sybase Inc. All rights reserved. |
![]() |