@IF

Removes or displays the content that follows this action based on a condition.

Should be followed by some content, then a @ENDIF action to mark the end of the content affected by the @IF.

Usage

<# @IF(condition) #>

Parameters

condition

(Required) The condition to evaluate

Examples

Example With these variables Result

Text before.
<# @IF(country = “Canada”) #>
A Canadian somewhere.
<# @ENDIF #>

country is "Canada"

Text before.
A Canadian somewhere.

Text before.
<# @IF(country = “Canada”) #>
A Canadian somewhere.
<# @ENDIF #>

country is "Belgium"

Text before.

Text before.
<# @IF(country = “Canada”) #>
A Canadian somewhere.
<# @ELSE #>
A non-Canadian somewhere.
<# @ENDIF #>

country is "Canada"

Text before.
A Canadian somewhere.

Text before.
<# @IF(country = “Canada”) #>
A Canadian somewhere.
<# @ELSE #>
A non-Canadian somewhere.
<# @ENDIF #>

country is "Belgium"

Text before.
A non-Canadian somewhere.

More information

The examples spread the content and the commands on multiple lines to make it easier to read. This is not required. A @IF can be placed in the middle of a paragraph if you need it.

Two other actions interact with @IF and @ENDIF: @ELSE and @ELSEIF.

Unlike the IF function, this @IF action only receives a condition. The content that follows the action (until a @ELSE, @ELSEIF or @ENDIF) is used as if_true value. If there is a @ELSE or @ELSEIF action, the content that follows it is used as if_false value.

You can nest @IF@ENDIF within another @IF@ENDIF. So if the outer @IF’s condition hides the content, the inner @IF will be ignored.

A more in-depth explanation for using @IF is available in the explanations: Clarifying @IF.

See also