if(criteria) Last updated: 31. May 2023

Evaluates a bool criteria such as a variable or statement and executes code if true.

Parameters

Name Type Description
criteria bool Bool statement or value to evaluate.

Returns

Nothing

Example

Data

{
"value1" : true,
"value2" : false
}

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#if(value1) {#
<b>If condition content</b>
#} else {#
<i>Else content</i>
#}#

Output

The #JS code above produces the output shown below:
<b>If condition content</b>

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
write("Test 1: ");
if(value1) write("true");

write("\r\r");
write("Test 2: ");
if (value2) write("true"); else write("false");

Output

The JS code above produces the output shown below:
Test 1: true

Test 2: false