Boolean operations
Pulsar supports boolean operations such as and
, or
but the syntax is a bit different than in other languages. Instead of operators, you use functions:
{[ if @and(var1, var2) ]}
Executes when both var1 and var2 == true
{[/]}
You can also chain boolean operations, using functions inside functions:
{[ if @and(var1, @or(var2, var3)) ]}
Executes when var1 == true and one of var2, var2 == true
{[/]}
The following boolean functions are available:
And
and
results to true when all statements were true. and
is a variadic function, and it can take as many parameters as you want:
{[ if @and(true, true, true, true, false) ]}
Never executes because one of the statements was false
{[/]}
Or
or
results to true when at least one of the statements is true. or
is a variadic function, and it can take as many parameters as you want:
{[ if @and(false, false, false, true, false) ]}
Executes because one of the statements was true
{[/]}
Not
not
negates the boolean value, meaning true
becomes false
and vice versa.
{[ if @not(false) ]}
Executes because false was negated to true
{[/]}
Note from developers: We are planning to add support for true operators as soon as possible, so consider this a workaround. For more complex logic, you should opt to use javascript helpers instead.
There are engine-related challenges with supporting operators that need to be solved before they can be implemented, especially about precedence controlled with brackets (var1 && var2) || var3
, as brackets are currently exclusively used for function invocations. If you would like to work on problems like this, consider joining our team!
Last updated
Was this helpful?