"range where ... " not working, simple "if" does

Doesn’t work, unfortunately, but thanks.

My “it’s a map of maps, not an array of maps” insight appears to be correct. If I do the following:

<!-- First construct a slice of maps, one entry per partner -->
{{ $allPartners := slice}}
{{ range $.Site.Data.partners }}
  {{ $allPartners = $allPartners | append . }}
{{ end }}

<!-- Now use "where" with the slice -->
<ul>
  {{ range where $allPartners "type" "partner"}}
    <li>{{ .title }} : {{ .type }}</li>
  {{ end }}
</ul>

then I get the expected output.

Strictly speaking this is following the letter of the documentation, but it’s surprising that “where” doesn’t work with maps-of-maps. Is this worth filing a bug / feature request for?

1 Like