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

0 Shares
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 %}
	<ul>
	{% for number in numbers %}
		<li>{{ number }}</li>
	{% endfor %}
	</ul>
{% 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 %}
	<ul>
	{% for Product_HowtoUse in Product_HowtoUses %}
		<li>{{ Product_HowtoUse }}</li>
	{% endfor %}
	</ul>
{% else %}
	{{ Product_HowtoUse }}
{% endif %}