Skip to content

Instantly share code, notes, and snippets.

@r-k-b
Last active July 20, 2017 05:58
Show Gist options
  • Select an option

  • Save r-k-b/6617f49ec6922050802471ff229f7e86 to your computer and use it in GitHub Desktop.

Select an option

Save r-k-b/6617f49ec6922050802471ff229f7e86 to your computer and use it in GitHub Desktop.
A quick way to inspect the contents of the Global Scope in Liquid Markup, using the browser's dev tools.
<script type='text/javascript' data-source='https://gist.github.com/r-k-b/6617f49ec6922050802471ff229f7e86'>
// # dump-liquid-scope-to-console
//
// A quick way to inspect the contents of the Global Scope in Liquid Markup, using the browser's dev tools.
(function () {
function decodeHtml(html) {
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
const globalsRaw = "{{ this | json | escape | replace: '\', '\\' | strip_newlines: '\n' }}";
window.globals = JSON.parse(decodeHtml(globalsRaw));
console.info('liquid globals:', globals);
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment