For a new theme I need to insert a CSS class with each even index of an array. The array holds the events of a timeline that flips the side with following event.
So, if the current array index modulo 2 equals 0, insert the CSS class. The difficulty is to get this working with the template functions. It should look similar to this (where currentIndex is a placeholder):
{{ if mod currentIndex 2 eq 0 }}class="timeline-inverted"{{ end }}
Update:
Now I found a way to get the current index but Hugo still threws an error because mod
takes two arguments but gets four (currendIndex, eq and 0).
{{ range $i, $e := .Site.Params.about.events }}
<li {{ if mod $i 2 eq 0 }}class="timeline-inverted"{{ end }}>