Skip to content

Boolean Functions

binary

ts
bool.binary(): integer

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

Input Example:

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

Output:

html
1
0

then

ts
bool.then(ifCase: any, elseCase?: any = nil): any

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

Arguments:

  1. ifCase (any) - The value to return if the receiver is true
  2. elseCase (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:

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

Output:

html
Yes
No