Hugo Version:
Hugo Static Site Generator v0.80.0/extended linux/amd64 BuildDate: unknown
Please look at this code:
{{ $loaded := 0 }}
{{ $isloaded :=0 }}
{{ range .Data.Pages }}
{ if le $loaded 10 }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a><br>
{{ $loaded }}
{{ $loaded := ( add $loaded 1 ) }}
{{ $loaded }}
{{ else if eq $isloaded 0 }}
...<br>
{{ $isloaded := 1 }}
{{ end }}
{{ end }}
I expect the output to be:
blah
0 1 blah
1 2 blah
....
But the output is
blah
0 1 blah
0 1 blah
....
It seems that Custom Variable does not change after iteration. It confused me. Why does that happen?( Is that some issue related to scopes? ) And any solutions?
Thanks for reading this post.