Previous Topic: PDM_FMT: Format Text from a Server Variable

Next Topic: PDM_INCLUDE: Inserting from a Different File


PDM_IF: Conditional Processing

These tags are used to conditionally include text. <PDM_IF> blocks can be placed anywhere in an HTMPL file - in HTML, in JavaScript, and even within HTML tags. <PDM_IF> and <PDM_ELIF> (else if) both take a simple conditional clause as their properties rather than name‑value pairs. If the clause is true, the text after the tag to the closing tag is included in the file; if the clause is false, the server discards the text between the tag and the closing tag. The closing tag can be <PDM_ELIF>, <PDM_ELSE>, or </PDM_IF>.

The <PDM_ELSE> and <PDM_ELIF> tags are optional. If both are specified, all <PDM_ELIF> tags must precede <PDM_ELSE>. There can be any number of <PDM_ELIF> tags between <PDM_IF> and <PDM_ELSE> (or </PDM_IF> if <PDM_ELSE> is omitted).

The syntax of the conditional in <PDM_IF> and <PDM_ELIF> is as follows:

op Value

Description

==

Equal to

!=

Not equal to

 

>=

Equal to or greater than (must be written as \>= or &gt;=)

<

Less than (must be written as \< or &lt;)

 

>

Greater than (must be written as \> or &gt;)

<=

Equal to or less than (must be written as \<= or &lt;=)

 

&

Performs a bit‑and of the left and right values. True if any bits are set; false if none are set.

%

Returns true if the left value is an even multiple of the right value, and false otherwise (useful for building two‑dimensional tables).

:

Performs a byte-oriented pattern match like the UNIX grep command. It returns true if the left value contains the regular expression defined by the right value.

Example:

<PDM_IF $count \>= 10> . . .
<PDM_ELIF $count &lt; 5>  . . .
<PDM_ELSE> . . .
</PDM_IF>

There can be more than one conditional in a PDM_IF statement. Conditionals are separated by connectors, either && (and) or || (or). There is no precedence for either connector. The web engine examines a conditional from left to right until it reaches a connector. If the initial condition is true and the connector is ||, it considers the entire condition to be true without further evaluation. If the initial condition is false and the connector is &&, it considers the entire condition to be false without further evaluation. Otherwise, it considers the condition undetermined, and evaluates the conditional from after the connector.