I’m trying to do the following :
{{ range $key, $value := (where $.Site.Data.downloads "type" "==" "release") }}
Currently, I have the following code that works :
<h2>Beta versions</h2>
{{ range $key, $value := $.Site.Data.downloads }}
{{ if eq $value.type "beta" }}
<h3>{{ $key }}</h3>
OVA : <a href="https://xxx.xxx.xxx/dl/{{ $value.OVA }}">{{ $value.OVA }}</a> (md5 <code>{{ $value.MD5 }}</code>)<br>
Update : <a href="https://xxx.xxx.xxx/dl/{{ $value.UPDATE }}">{{ $value.UPDATE }}</a>
{{ end }}
{{ end }}
But it’s limited in the way that when there is no beta version, I am displaying the title anyway.
So I was trying to clean the code a bit and start with looping over the filtered list as the documentation seems to indicate it’s possible. The JSON is like the following :
{
"2.2":{
"type":"release",
"OVA":"NAbox-2.2.ova",
"OVALink":"http://xxx.xxx.xxx/dl/NAbox-2.2.ova",
"UPDATE":"NAbox-2.2.tgz",
"UpdateLink":"http://xxx.xxx.xxx/dl/NAbox-2.2.tgz",
"MD5":"e49bfcb5ef81eb1cb317a6fd258bae73"
},
"2.1.5":{
"type":"release",
"OVA":"ADVA-2.1.5.ova",
"OVALink":"http://xxx.xxx.xxx/dl/ADVA-2.1.5.ova",
"UPDATE":"adva-2.1.5.tgz",
"UpdateLink":"http://xxx.xxx.xxx/dl/adva-2.1.5.tgz",
"MD5":"d67291a132a5fd0b85f703d77997527f"
}
}
Ideally, I would like to display a beta download section only if there is anything type=“beta”, same for the stable release.
Thoughts?