Debugging Objects in Shopify Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script>console.log({{ product | json }});</script> |
Thanks a lot!
What are you doing when you have larger objects and JSON isn't allowed?
Shopify/liquid#1153
json not allowed for this object
I accessed the properties of the object until it allowed me to do it in my last project.
For example...
<script>console.log({{ product.images | json }});</script>
When I first posted this product
supported JSON, but I guess now it doesn't.
This snippet was a quick way of me examining the object without looking at the docs, maybe not quite as useful now.
Thanks
Good job
thanks so much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx! It works. But not everywhere. E.g. in product-template.liquid I was able to get the log when inserting it above the div with the product description: