If not true (!true)

Acidic9 picture Acidic9 · Dec 22, 2016 · Viewed 39.1k times · Source

In golang's template/html package, I can use {{ if .loggedIn }} to check if logged in is true.

How do I check if .loggedIn is false without using ne or eq?


For example, I am looking for something like

{{ if !.loggedIn }}
<h1>Not logged in</h1>
{{ end }}

Answer

hlscalon picture hlscalon · Dec 22, 2016

Use the function not:

{{ if not .loggedIn }}
<h1>Not logged in</h1>
{{ end }}