Back to Hugo

not

docs/content/en/functions/go-template/not.md

0.161.1503 B
Original Source

Unlike the and and or operators, the not operator always returns a boolean value.

go-html-template
{{ not true }} → false
{{ not false }} → true

{{ not 1 }} → false
{{ not 0 }} → true

{{ not "x" }} → false
{{ not "" }} → true

Use the not operator, twice in succession, to cast any value to a boolean value. For example:

go-html-template
{{ 42 | not | not }} → true
{{ "" | not | not }} → false

{{% include "/_common/functions/go-template/text-template.md" %}}