Skip to main content
Version: v2

Boolean Functions

binary

binary(): int

Returns an integer 1 if the receiver is true, 0 otherwise

Input example

{{ true.binary() }}
{{ false.binary() }}

Output

1
0

then

then(consequence: any, alternative?: any = nil): any

Returns the consequence if the receiver is true, otherwise returns the alternative. The alternative is optional and defaults to nil

Arguments

  1. consequence (any) - The value to return if the receiver is true
  2. alternative (any) - The value to return if the receiver is false. Default is nil, which will be converted to an empty string when rendered in the template

Input example

{{ true.then("Yes", "No") }}
{{ false.then("Yes", "No") }}
{{ false.then("Yes") }}

Output

Yes
No