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 %}
]"
User | Count |
---|---|
420 | |
208 | |
109 | |
89 | |
86 |