I want to display a joined list of post categories if set, or default alternate text if not (pseudo code)
if post categories
categories.join(', ')
else
default text
end
How would that be accomplished in a micro.blog template?
Thanks!
I want to display a joined list of post categories if set, or default alternate text if not (pseudo code)
if post categories
categories.join(', ')
else
default text
end
How would that be accomplished in a micro.blog template?
Thanks!
I’ve figured this out with help from here: Error calling delimit: can't iterate over <nil> - #2 by regis - support - HUGO
{{ if .Params.categories }}
{{ delimit .Params.categories ", " }}
{{ else }}
Post
{{ end }}
If you skip the if
block and just do delimit
, then you may run into a nil
error resulting from trying to iterate over a nil
value.