I suppose this should be evident for people used to liquid syntax, but I don’t find how to do it.
I have to create a list of objects with properties and values in a variable to pass it to an include, and don’t know how to do it.
I have tried using capture/endcapture and strings, but
Something like this:
Yes, but may be I have not explained it correctly.
I know I can do that kind of structures in a source file, create a list like that and then using liquid navigate that lists.
But I am trying to create that objects in memory dynamically using liquid.
I need to extract info from the collections, create a list with that structure and pass it to theme includes that expect the data collection be organized with some specific structure.
Let me simplify the example to the maximum
I want to create a key/valu pair using liquid, something like
{% assign s=’{“name”,“value”} %}
Process s with whatever filter is appropiate (split?)
{% assign v= s|filterx %}
like this? though that is just values not key pairs.
maybe this:
If not, more info on your use case would help - sometimes the thing you are trying to accomplish can be done in a different way than the specific thing you are asking, though it sounds like you know what you are doing so you are probably fine.
I don’t work much with arrays like that, others may have a lot better info.
So, you only can create arrays and access it numeric ID?
I mean i that example, after splitting the array you have to access the key/valu pairs as
pair_arr[0] for the key and pair_arr[1] for the value.
You cannot access the object by the key name?, something like
{ book.title } (should display title1)
you have to search for the pair that has “tittle” in pair_arr[0] and then get the value in pair_arr[1].
I was trying to reuse some includes that relay in passing them collections of elements like pages collection.
So the list of categories I pass them should have the same properties.
I can construct an array, but if you have to access it using the position and it won’t work.
I would like to pass them a collection of elements constructed for infor extracted from other elements, but that it is not in a source file.
For example pass a list of collection and subcategories to an include that expect a collection of pages to generate a menu using the title of the pages.
I don’t know - I’m don’t really use arrays like that, so can’t really help much. Hopefully someone else will chime in, I can’t really say one way or another, most of what I do is using a data file.