Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created May 24, 2019 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/d50506e98d75b98d9102a57cd21c5775 to your computer and use it in GitHub Desktop.
Save whoisryosuke/d50506e98d75b98d9102a57cd21c5775 to your computer and use it in GitHub Desktop.
Shopify - Dump/print variables in console using snippet - via: https://github.com/Shopify/liquid/issues/121#issuecomment-266620549

Create a snippet named "dump.liquid" with the following code snippet
Note: if you use a different filename for the liquid snippet, make sure the variable being passed through liquid's json filter is also the same name, otherwise this shorthand usage won't work as expected

'dump.liquid'
<script type="text/javascript">
 console.log("Dumping");
 console.log({{ dump | json }});
</script>

Usage in template files:
{% include 'dump' with [OBJECT] %}

Example: Used within product.liquid template file
'product.liquid' {% include 'dump' with product %}

Open Chrome console and you will see an object that you can drill into and explore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment