I have a question about object menus which is similar to linklist. It has a weird behavior.
Here is the code. Lines 6-9 contains 4 similar instructions to get menu from the menus object:
{% for link in linklists.main-menu.links %}
{% if collection.handle == link.handle %}
<p>test</p>
{% endif %}
{% assign linkTitleHandleize = link.title | handleize %}
<p>menu[collection.handle] returns {{ menus[collection.handle] }}</p>
<p>menu["bags"] returns {{ menus["bags"] }}</p>
<p>menu[link.handle] returns {{ menus[link.handle] }}</p>
<p>menu[linkTitleHandleize] returns {{ menus[linkTitleHandleize] }}</p>
{% endfor %}
So the html output is:
test
menu[collection.handle] returns EmptyDrop
menu["bags"] returns EmptyDrop
menu[link.handle] returns LinkListDrop
menu[linkTitleHandleize] returns LinkListDrop
For some reason, menus object returns expected "bags" menu array only when key is link.handle or transformed link.title | handleize (keep in mind that variable linkTitleHandleize is just a plain string) .
If I'm trying to pass same string but by collection.handle or even by plain string (in my case it is "bags") then menus returns nothing. I'm very confused, since the strings are equal (see condition on line 2 - it returns true and "test" is rendering) This is a very strange behavior and before this day I thought I know Liquid very well.
UPD: I have to rephrase my question. It is not about how to create a working version of code. It is a sort of research: why Liquid returns EmptyDrop for menu[collection.handle] and for menu["bags"] and why it returns LinkListDrop for menu[link.handle] and for menu[linkTitleHandleize] in case when linkTitleHandleize = link.handle = collection.handle = "bags". Thank you!