Show/Hide Toolbars

 PhraseExpander 5 Manual

Navigation: Designing templates > Macros > Flow

If

Scroll Prev Top Next More

The If macro allows you to change the flow of the template based on the evaluation of an expression.

 

For example, you can use this conditional block to change the message that is displayed based on the value of a variable.

 

The If macro window

The If macro window

 

 

Description

1.Conditions criteria: they tell how the conditions will be processed (you can choose if the final expression is true by matching any or all conditions). Conditions can work on strings, numbers and dates (the current culture is used to parse dates)

2.Conditions: a list of the conditions to match for the statement to be true

3.If statement (or true statement): it contains the expression that will be executed if the condition is true

4.Else statement (or false statement): it contains the expression that will be executed if the condition is false

5.Label: lets you easily identify the if section in the template. This is optional and for reference only

6.Case sensitive comparison: when this option is selected the comparison considers the casing of the expression in the if (e.g. ABC is different from abc)

7.Display inline: if checked, the if macro will be displayed on the same line (no new line after the {#if#} marker).

 

Syntax

 

{#if condition#}

true clause

{#else#}

false clause

{#endif#}

 

condition: the condition to evaluate. Based on that, the macro will execute either the true clause or the false clause.

[desc]: the label that describes the if block. This is optional and for reference only

[exact]: if set, it matches the conditions exactly (case sensitive comparison)

[matchAll]: if set, it matches all the conditions for the statement to be true (the conditions are in AND)

true clause: it's executed if the condition is true

false clause: it's executed if the condition is false (the else statement is optional)

 

Example

Template:

{#if {{Total}} <= 6#}Recovered{#endif#}

 

Result:

Checks the value of the {{Total}} variable. If it's less or equal than 6, it displays the if branch, otherwise the else branch.

 

Created with Help & Manual 7 and styled with Premium Pack Version 3 © by EC Software