Shopify themes, liquid, logos, and UX
I have a variable, myArray, that I want to simply pass through a Liquid template to be displayed to an end user. Liquid seems to compress all of the array items into a single string. This is what happens:
# the array
myArray = ["item 1", "item 2"]
# the string I pass to Liquid to be stored as a template and then parsed
"My Array Items: {{myArray}}"
# the final results after I call template.parse
"My Array Items: item1item2"
What I want is the following:
"My Array: ["item1", "item2"]"
Can you give a little bit better of an example? I'm a little bit confused because it looks like you're writing javascript but you're using liquid.
Sure, sorry. (Very new to Liquid, using it in Ruby). I added quotations where there should have been some to indicate strings.
fwiw, the following is a loose workaround -- basically iterating over the array to create a stringified array.
"My Array: [
{{% for item in myArray %}
{{tag}},
{% endfor %}
]"
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024