Type filters allow you to convert values of one type into other types.

boolean

Attempts to convert a string value into a Boolean. If the value is already a Boolean, it will be returned unchanged. If the value cannot be converted into a Boolean, null will be returned.

This filter will also accept "on", "enabled", or "yes" as true, and "off", "disabled", and "no" as false.

Code
{{ true | boolean }}
{{ 'false' | boolean }}
{{ 'enabled' | boolean }}
{{ settings['something/enabled'] | boolean | default: false }}
Output
true
false
true
false

decimal

Attempts to convert a string value into a decimal number. If the value is already a decimal number, it will be returned unchanged. If the value cannot be converted into a decimal number, null will be returned.

Code
{{ 10.1 | decimal }}
{{ '3.14' | decimal }}
{{ 'text' | decimal | default: 3.14 }}
Output
10.1
3.14
3.14

integer

Attempts to convert a string value into an integer. If the value is already an integer, it will be returned unchanged. If the value cannot be converted into an integer, null will be returned.

Code
{{ 10 | integer }}
{{ '10' | integer }}
{{ '10.1' | integer }}
{{ 'text' | integer | default: 2 }}
Output
10
10

2

string

Attempts to convert a value into its string representation. If the value is already a string, it will be returned unchanged. If the value is null, null will be returned.