How to write a conditional in Go Lang like this:
File: view.html
{{ if(var1 =="" && var2 =="" }}
ALL EMPTY
{{else}}
DISPLAY
{{END}}
How to write a conditional in Go Lang like this:
File: view.html
{{ if(var1 =="" && var2 =="" }}
ALL EMPTY
{{else}}
DISPLAY
{{END}}
Templates don't have operators, but they have function eq
, which takes two arguments and returns true if they are equal, and function and
which also takes two arguments and returns true if they're both true. So you could write the first line in your code as:
{{if (and (eq var1 "") (eq var2 ""))}}