{{- range $i, $_ := .content -}} {{- $type := (default "link" .type) -}} {{- $desc := .desc -}} {{- if (eq (len $.content) 1) -}} {{- $desc = (default $.text $desc) -}} {{- else -}} {{- if (and (not (isset . "desc")) (not (eq $type "text"))) -}}{{- errorf "Missing description for content %s" .data -}}{{- end -}} {{- end -}} {{- if (and (or (gt (len $.content) 1) (eq $type "text")) (eq $i 0)) -}}{{- $.text -}}: {{- end -}} {{- if (gt $i 0) -}}, {{ end -}} {{- if (eq $type "link") -}} {{ $desc }} {{- else if (eq $type "text") -}} {{- .data -}} {{- else if (eq $type "resource") -}} {{- $resource := $.resources.GetMatch .data -}} {{ $desc }} {{- else -}} {{- errorf "Unknown content type %s" $type -}} {{- end -}} {{- end -}}