How can I do an if/or, or can i use a switch statement?

I’ve tried {{ if (eq $class "left") || (eq $class "right") }}, but I’m getting “unexpected | in if”. If I’m understanding the Go documentation, || should be the correct way to do this.

I haven’t looked up how to do C-style switch/case statements in Go, but if || doesn’t work, are they possible too?

You must look at the Go template documentation, which have a or not ||.

Also no switch statements in Go templates.

1 Like

I got it; I was using the wrong syntax. I’m not used to the operator operand operand way of doing things.

If you’re coming here from google, the correct way of doing it would be {{ if or (eq $class "left") (eq $class "right") }}

2 Likes