Comma separated list in Liquid
Solution 1:
You might find my answer to this similar question helpful.
-
Append each field to a string with a separator:
{% assign metadata = "" %} {% if asset.metadata['field01'] %} {% capture metadata %}{{ metadata | append: asset.metadata['field01'] | append: "|" }}{% endcapture %} {% endif %} <!-- repeat for fields 2 & 3 -->
-
Use
split
andjoin
to format the string for output:{{ metadata | split: "|" | join: ", " }}
This will ensure you don't get a trailing comma in your output.