Created
November 13, 2025 13:21
-
-
Save ConduciveMammal/8973a3f9935486522b7290ae9b43a7f7 to your computer and use it in GitHub Desktop.
Liquid Debug Snippet
This file contains hidden or 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
| {%- doc -%} | |
| Outputs the provided Liquid value to the browser console for debugging. | |
| @param {string} [title] - Optional label for the instance | |
| @param this - The instance content to debug | |
| @param {boolean} [json] - If true, also logs a parsed JSON version of the instance | |
| @example | |
| {% render 'debug', this: shop.metafields.services.title, json: true %} | |
| {% render 'debug', this: product.images, json: false %} | |
| {%- enddoc -%} | |
| {%- liquid | |
| if title != blank | |
| assign label = title | |
| else | |
| assign label = 'DEBUG' | |
| endif | |
| -%} | |
| <script> | |
| console.group('%c{{ label }} Debugging', 'color: orange; font-weight: bold;'); | |
| {% if json %} | |
| console.log('%cJSON:', 'color: #00CC66; font-weight: bold', JSON.parse('{{ this | json }}')) | |
| {% endif %} | |
| console.log('%cRaw:', 'color: #009933; font-weight: bold', '{{ this }}') | |
| console.groupEnd(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment