Using this everything works:
{{ $goals := getJSON "./static/dist/js/goals.json" }}
{{ $currentGoal := .Params.id }}
{{ range $goals.goals }}
<pre>
debug:
.id: {{ .id }}
$currentGoal: {{ $currentGoal }}
</pre>
{{ end }}
But if I try a where
or even an if eq
inside the loop, nothing appears!
{{ $goals := getJSON "./static/dist/js/goals.json" }}
{{ $currentGoal := .Params.id }}
{{ range $goals.goals "id" $currentGoal }}
<pre>
debug:
.id: {{ .id }}
$currentGoal: {{ $currentGoal }}
</pre>
{{ if eq ".id" "1" }}
foo 1
{{ end }}
{{ if eq "id" "1" }}
foo 2
{{ end }}
{{ if eq .id "1" }}
foo 3
{{ end }}
{{ if eq "id" 1 }}
foo 4
{{ end }}
{{ end }}
goals
is an array of objects inside the JSON.
Please, what am I doing wrong?