Handlebars Helpers
If
The "IF" helper is used to conditionally render a block of text based on the truthiness of a data point.
Important
This helper can only be used to evaluate the truthiness of a variable, this means you cannot use any comparison operators like ==
, ===
, !=
, !==
, >
, <
, >=
, <=
.
You also can't do any arithmetic operations or any other expressions.
You will get an error on the _create
action when a new stub is created, if you try to use any of the above operations.
This an official Handlebars helper.
See the official Handlebars helper documentation for each
Example: Basic IF Conditional Rendering
This example shows how to conditionally render a block of text based on the value of a variable.
Example definition:
If the is_admin
variable is true
, the output will be:
If the is_admin
variable is false
, the output will be empty.
Example: IF-ELSE Conditional Rendering
This example shows how to conditionally render a block of text based on the value of a variable.
Example definition:
If the is_admin
variable is true
, the output will be:
If the is_admin
variable is false
, the output will be:
Example ERROR
!This cannot be done!
ERROR
This will throw an error on the _create
action when a new stub is created.