title |
linktitle |
description |
date |
publishdate |
lastmod |
categories |
menu |
keywords |
signature |
workson |
hugoversion |
relatedfuncs |
deprecated |
aliases |
truth |
truth |
Creates a `bool` from the truthyness of the argument passed into the function |
2023-01-28 |
2023-01-28 |
2023-01-28 |
|
|
strings |
boolean |
bool |
truthy |
falsey |
|
|
|
|
|
false |
|
Useful for turning different types into booleans based on their truthy-ness.
{{ truth "true" }} → true
{{ truth "false" }} → true
{{ truth "TRUE" }} → true
{{ truth "FALSE" }} → true
{{ truth "t" }} → true
{{ truth "f" }} → true
{{ truth "T" }} → true
{{ truth "F" }} → true
{{ truth "1" }} → true
{{ truth "0" }} → true
{{ truth 1 }} → true
{{ truth 0 }} → false
{{ truth true }} → true
{{ truth false }} → false
{{ truth nil }} → false
{{ truth "cheese" }} → true
{{ truth 1.67 }} → true
This function will not throw an error. For more strict behavior, see bool
.