Hello,
Liquid currently lacks a lot in the array manipulation area, but there are a lot of tricks to workaround. One common trick is to create an array from a variable using the sort filter:
for media in product.media
assign media_as_array = media | sort
endfor
Which then allows to concat it to another array. The issue is that currently the type is lost, so while media is properly typed as "media", after the sort operation it becomes untyped[]
Until we can have better array functions, could the typing be improved so that the type is preserved?
Thanks!
Hello,
Liquid currently lacks a lot in the array manipulation area, but there are a lot of tricks to workaround. One common trick is to create an array from a variable using the sort filter:
Which then allows to concat it to another array. The issue is that currently the type is lost, so while media is properly typed as "media", after the sort operation it becomes untyped[]
Until we can have better array functions, could the typing be improved so that the type is preserved?
Thanks!