Split meta field/variable and for loop to display in Shopify

0 Shares
0
0
0
0
0
0
0

Hoping to enter individual lines of text into a meta field and then use the split filter, loop through the lines and output as UL

with Variable

{% assign numbers = '5,10,2,8,9,1,10,8,7,3,8,4,6' | split: ',' %}
{% if numbers > 1 %}
	
    {% for number in numbers %}
  • {{ number }}
  • {% endfor %}
{% else %} {{ numbers }} {% endif %}

with Meta Fields

{% assign Product_HowtoUse = product.metafields.Product.How_to_use %}
{% assign Product_HowtoUses = Product_HowtoUse | split: '|' %}
{% if Product_HowtoUses.size > 1 %}
	
    {% for Product_HowtoUse in Product_HowtoUses %}
  • {{ Product_HowtoUse }}
  • {% endfor %}
{% else %} {{ Product_HowtoUse }} {% endif %}