.if Macro

This macro is used for conditional generation.

.if[not] condition
		output
	[(.elsif[not] condition
		output)*]
	[.else
		output]
.endif [(tail)]

The following parameters are available:

Parameter

Description

condition

Specifies the condition to evaluate, in the form:
variable [operator comparison]
Where comparison may be :
  • Text, or a simple template

  • true or false

  • null or notnull

If no operator and condition are specified, the condition evaluates to true unless the value of the variable is false, null, or the empty string.

If variable and comparison are not integers, the operators perform a string comparison that takes into account embedded numbers. For example:
Class_10 > Class_2

You can chain conditions together using the and or or logical operators.

Type: Simple template

output

Specifies the output if the condition is true.

Type: Complex template

tail

[optional] Specifies text to be generated after the output, unless the output is empty.

Type: Text

Examples
Simple .if block:
.if %Abstract%
		This class is abstract.
.endif
Result (if the Abstract property is selected):
This class is abstract.
With two conditions and an .else clause:
.if (%Abstract%==false) && (%Visibility%=="+")
		This class is public and concrete.
    .else
This is not a public, concrete class.
.endif
Result (if the Abstract property is not selected and the Visibility property is set to Public):
This class is public and concrete.
With an .elseif clause:
.if (%Abstract%==false) && (%Visibility%=="+")
		This class is public and concrete.
.elsif (%Visibility%=="+")
		This class is public.
    .else
This is not a public, concrete class.
.endif