not

Inverts the truthiness of the value, following the same rules as a template `if`.

Booleans go by their value, numbers are true when greater than zero, strings are true when non-empty (except the literal "false"), and collections are true when non-empty. An unrecognized type is falsey, so Not returns true for it.

nil is the one value Not will not invert. A missing key and a key holding an explicit null both arrive here as nil, and inverting either one turns a misspelled path into a confident true. Say what absence means with a default ahead of it, as in {{ flag | default:false | not }}.

InputArgumentsReturnsanyno argumentsbool
Source
BasicSource

Inverts truthiness the same way a template `if` reads it, so a non-empty string is truthy and not makes it false.

Given

{"name": "Ada"}

Template

{{ name | not }}

Result

false
Empty stringSource

Treats an empty string as falsey, so not reports it as true.

Given

{"name": ""}

Template

{{ name | not }}

Result

true
False stringSource

Treats the literal string "false" as falsey, matching how a template `if` reads it, so not returns true.

Given

{"flag": "false"}

Template

{{ flag | not }}

Result

true
ZeroSource

Treats zero as falsey, so not reports it as true.

Given

{"count": 0}

Template

{{ count | not }}

Result

true