Hi! I’ve got a JSON file with, say, data about sponsors. This JSON is placed within the data
directory. The contents are something like this:
{
"three": {
"logo": "/images/sponsors/pt-spon-three.png",
"class": "Platinum",
"url": ""
},
"four": {
"logo": "/images/sponsors/pt-spon-four.png",
"class": "Platinum",
"url": ""
},
"six": {
"logo": "/images/sponsors/gl-spon-one.png",
"class": "Gold",
"url": ""
},
}
I am trying to split the sponsors on my page using a partial. The partial is like:
<h5>Platinum Sponsors</h5>
<div class="block text-center">
<!-- Sponsors image list -->
<ul>
{{ range where .Site.Data.sponsors "class" "Platinum" }}
<li>
<div class="image-block">
<a href="{{ .url }}">
<img src="{{ .logo }}">
</a>
</div>
</li>
{{ end }}
</ul>
</div>
<h5>Gold Sponsors</h5>
<div class="block text-center">
<!-- Sponsors image list -->
<ul>
{{ range where .Site.Data.sponsors "class" "Gold" }}
<li>
<div class="image-block">
<a href="{{ .url }}">
<img src="{{ .logo }}">
</a>
</div>
</li>
{{ end }}
</ul>
</div>
Nothing gets displayed on the page on including this partial. When I remove the where
clause, the list of sponsors shows, except, (obviously) it’s not filtered based on the class.
Could someone please point me in the right direction to get where
working with data entries? I’m missing something critical to the working of this, and am unable to find what.
Update: I tried using the same principle, except this time, I used YAML files instead of a JSON. The result is the same.