ok, thats cracy. That means for me (and others), that i have to write a script, which generates a uniq_id and write that in the coresponding front matter.
{{ range $index, $page := $value.Pages }}
{{ $c :=add $index 1 }}
{{ $c }}= value of $c...
{{ if eq ( mod $c 4 ) 1 }}
{{ $c }} first one of each 4... ($c=1,5,...)
{{ end }}
{{ end }}
$index counts up as expected, {{ $c }} prints out the value of c, but the if-clause is in 0.13 broken.
after reading the reported issue and the coresponding discussion, maybe someone find my temporary workaround useful: don’t mix up fixed/raw numbers with calculated ones. Use only calculated…
instead of
{{ if eq ( mod $c 4 ) 1 }}
use:
{{ if eq ( mod $c 4 ) (add 1 0) }}
but {{ add 0 0 }} is not working for 0, use {{ sub 1 1 }} …
I found another method without depending on the index var which might be at times a string when having a dictionary, and also with being able to sort array…
{{ $.Scratch.Set "counter" 0 }}
{{range sort .Params.employees}}
{{ $.Scratch.Set "counter" (add ($.Scratch.Get "counter") 1) }}
I am the number {{$.Scratch.Get "counter"}} in loop!
{{end}}
Just a small fix, you can use Add method directly.
{{ $.Scratch.Set "counter" 0 }}
{{range sort .Params.employees}}
{{ $.Scratch.Add "counter" 1) }}
I am the number {{$.Scratch.Get "counter"}} in loop!
{{end}}