Your second untested example works perfectly well (thanks!) but since I need to print out the image x times, I’m unable to use it.
I really can’t understand why the first example doesn’t work, the error I get in the console is:
ERR: template: theme/shortcodes/froth.html:9:17: executing "theme/shortcodes/froth.html" at <.Get>: can't evaluate field Get in type int
To confirm, the code I’m using is:
{{ range $i, $sequence := (seq 5) }} {{ if lt (int (.Get "rating")) 4 }} <img src="/img/icons/full.svg"/> {{ else }} <img src="/img/icons/empty.svg"/> {{ end }} {{ end }}
If it helps, my Hugo version is:
Hugo Static Site Generator v0.16 BuildDate: 2016-06-06T13:29:38+01:00
And I’m running it with the following command:
hugo server --buildDrafts --theme=latte --renderToDisk --verbose
UPDATE
After debugging it some more, I’ve managed to find out some information that might help.
If I print out the .Get outside of the range loop, the value gets printed, but if I define it inside the loop, I get an error. For example, the following results in the value of the rating printed before the image.
{{ range $i, $sequence := (seq 5) }}
<img src="/img/icons/rating.svg/>
{{ end }}```
The following does **not** work, because the .Get is inside the range, the error I get is ```'can't evaluate field Get in type int'```:
{{ range $i, $sequence := (seq 5) }}
{{ .Get “rating” }}
<img src="/img/icons/rating.svg/>
{{ end }}```