Reputation: 41
How to write a conditional in Go Lang like this:
File: view.html
{{ if(var1 =="" && var2 =="" }}
ALL EMPTY
{{else}}
DISPLAY
{{END}}
Upvotes: 4
Views: 5669
Reputation: 3274
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 ""))}}
Upvotes: 9