问题
I have a javascript that makes a api call and gets a json response. I need to pass this to my liquid template and iterate over it.
How do i pass the result variable on get request to a shopify liquid variable.?
Thanks..!
回答1:
You cannot do that. Liquid is rendered Server Side... whereas your Javascript is considered to be client side coding. When you are rendering your Liquid, you can transfer Liquid into Javascript for use later, but not vice versa.
Also, if you are getting JSON via an API call and you need to iterate over it, why are you not just using Javascript. You do not need Liquid to iterate over data.
来源:https://stackoverflow.com/questions/25738337/how-to-pass-javascript-api-request-result-variables-to-shopify-liquid-variable