Chapter 9 Generation Reference Guide (GTL)


Sharing conditions

A template can contain a condition expression. You can also create templates to share long and fastidious condition expressions:

Template name Template value
%ConditionVariable% .bool (condition)

Instead of repeating the condition in other templates, you simply use %ConditionVariable% in the conditional macro:

.if (%ConditionVariable%)

Example

The template %isInner% contains a condition that returns true if the classifier is inner to another classifier.

.bool (%ContainerClassifier%!=null)

This template is used in the %QualifiedCode% template used to define the qualified code of the classifier:

.if (%isInner%)
%ContainerClassifier.QualifiedCode%::%Code%
.else
%Code%
.endif

 


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