My program gets data from a TOML file for an embedded struct named Data:
===
[custom]
Data = [
{ filename = "fb.jpg", alt = "FB logo", url = "facebook.com" },
{ filename = "pi.jpg", alt = "Pinterest logo", url = "pinterest.com"},
{ filename = "twit.jpg", alt = "Twitter logo", url = "twitter.com"},
]
===
It's declared as interface so I don't know the field names in advance. I want to loop through the rows and build an image in HTML. I can iterate like this successfully. This obviously prints out each column value at a time:
{{ with .FrontMatter.Custom.Data }}
{{ range $_, $value := . }}
{{ range $_, $t := $value}} {{$t}}, {{end}}
{{ end }}
{{ end }}
But for the life of me I can't get access to the individual fields. I want to do this but it causes a runtime error:
{{ range $_, $t := $value}} {{index $value "filename" }}, {{end}}
How can I get hold of $value.filename, $value.alt and so on?