Conditional statements and iterations
In this section, we'll take a look at the conditional and looping statements that are available at compile time.
if...elseif...else
The if statement checks whether a preprocessor variable is set to a certain value. If it is, the markup between the opening if
statement and the closing endif
will be compiled. Optionally, it can be followed by an elseif
or else
statement, allowing you to compile other code if the initial condition is false. The entire block must end with endif
. The following snippet is an example that only compiles a Property
element if the preprocessor variable myVar
is equal to 10:
<?if $(var.myVar) = 10 ?> <Property Id="newProperty" Value="5" /> <?endif?>
Here's a more complex example that utilizes the elseif
and else
statements:
<?if $(var.myVar) = 10 ?> <Property Id="newProperty" Value="5" /> <?elseif $(var.myVar) > 10?> <Property Id="newProperty" Value="6" /> <?else?> <Property Id=...