Range of .Params as a comma delimited string?

How do you output a range of .Params as a comma delimited string without whitespace or line breaks?

{{ range where .Site.Pages.ByDate.Reverse "Section" "listings" }} {{ if (isset .Params "solddate") }} {{ else }} {{ if (isset .Params "partnumber") }} {{ .Params.partnumber }} {{ end }} {{ end }} {{ end }}

Desired output would look similar to this: 13312340,13312341,13312343,13312349,13312350

I used the script below to separate multiple tags with a comma:

{{ if isset .Params "solddate" }}
    {{ $paramLen := len .Params.solddate }}
    {{ if gt $paramLen 0 }}
        {{ range $k, $v := .Params.solddate }}
        	{{ $v }}
	        <!-- The comma will be inserted below -->
	        {{ if lt $k (sub $paramLen 1) }},{{ end }}
        {{ end }}
    {{ end }}
{{ end }}

This script is a bit bulky but the next release of Hugo will provide a much more elegant syntax:

{{ delimit (slice "foo" "bar" "buzz") ", " }}

I’m pretty sure that delim is part of Hugo 0.15.

1 Like

But not slice, because I’m the one who added this template func recently:

2 Likes

Are there any a new way in Hugo 0.16 to replace the comma to the dot at the end of the range output?

{{ range $authors }}
{{ . }},
{{ end }}