liquidMethodMissing doesn't support object promises #308
Replies: 6 comments
-
I'm not familiar with Shopify themes, can you provide a specific use case in template? I can update that type.
|
Beta Was this translation helpful? Give feedback.
-
appreciate your prompt response. I wouldn't say it is specific to Shopify templates. You can refer to this use cases in liquid: In my case, i would need to call nested properties of a drop, for example in the test cases we have:
this works fine, because the liquidMethodMissing returns a string for name, but what if we need to render something like obj.name.first? or obj.addresses |
Beta Was this translation helpful? Give feedback.
-
More info in the issue, i don't think that the return type is the only issue here. The drop implementation will return liquidMethodMissing in case the property wasn't present in the object, and will depending on the implementation, it might return a promise or a value. However, getFromScope implementation doesn't support promises in path, for example, assume:
if we do: the getFromScope will iterate the paths, the first iteration will resolve liquidMethodMissing with arg "some_product_handle" and returns a promise, second iteration will try to read the key (in above case is "name"), but will fail because the promise was not yet resolved. |
Beta Was this translation helpful? Give feedback.
-
I was able to resolve the issue by adding a simple condition to the readProperty function, i am not sure if it breaks something else!
|
Beta Was this translation helpful? Give feedback.
-
Then it's a bug, we should fix it. Thank you for your work! |
Beta Was this translation helpful? Give feedback.
-
As we tried in #285, there's no easy way to implement. Basically we need change every and each property reading and expression evaluation to async. Let's see if there's more people need async |
Beta Was this translation helpful? Give feedback.
-
Hi,
In attempt to implement a drop, i am trying to return an object from liquidMethodMissing method in order to lazily load objects.
For example:
and to call it as, for example: {{products['product handle'].name]}}
However, it seems that liquidMethodMissing supports only string type Promises.
Beta Was this translation helpful? Give feedback.
All reactions