Hello,
I have got a map and I would like to filter the values and concat all values to a comma separated string. In YAML the map shows:
socialmedia:
-
name : "mail"
url: "mailto:anybody@foo.com"
-
name : "github"
url : "http://github.com/anybody
-
name : "facebook"
url : "http://facebook.com/anybody"
I would like to get all url-values except the item with name == “mail” and build a string. The result should be a string like
"http://github.com/anybody", "http://facebook.com/anybody"
How can I do this? I have tried to do it with range and where, with this I can build the list, but the concatination of the url is incorrect, beause I get a comma at the end and with delimit I’m failing to exclude the element. So my current idea is
{{- range .Site.Params.socialmedia -}}
{{- if not (eq .name "mail") -}}
{{ .url }},
{{- end -}}
{{- end -}}
I’m using Hugo 0.18, thanks for help