Multiple if conditions in template

3,033 views
Skip to first unread message

Ollie Castle

unread,
Mar 7, 2013, 3:41:41 PM3/7/13
to golan...@googlegroups.com
I am trying to do a multiple condition if statement on a html golang template and have ended up implementing it like this:

{{if .Event.Track.HasElevation}}{{if .Event.Track.HasHeartRate}}{{if .Event.Track.HasCoordinates}}
{{end}}{{end}}{{end}}

Is it possible to do it in one if statement in golang?

Rémy Oudompheng

unread,
Mar 7, 2013, 3:45:27 PM3/7/13
to Ollie Castle, golan...@googlegroups.com
Try: {{if and .Event.Track.HasElevation .Event.Track.HasHeartRate
.Event.Track.HasCoordinates }}

Rémy.

Oliver Castle

unread,
Mar 7, 2013, 3:46:51 PM3/7/13
to Rémy Oudompheng, golan...@googlegroups.com
Perfect, that did the job, thanks
Reply all
Reply to author
Forward
0 new messages