bool_string Twig Filter

The bool_string filter converts a boolean-like value to a true or false value string value. Where the bool filter will return a boolean value, this will return a boolean value as a string. 

A boolean-like value can be:

  • true
  • false
  • yes
  • no
  • 1
  • 0
This filter is unique to Aptuitiv. It is not part of the core Twig functionality.
{{ variable|bool_string }}

For example, if the variable value was "yes", then bool_string would return "true".

This can be useful if you need to output a boolean value for some inline Javascript.

<script>
someFunction({{ myBooleanVariable|bool_string }})
</script>

If myBooleanVariable held a value of true, "yes", "true", "1", or 1, then the output would be:

<script>
someFunction(true)
</script>
This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv