Last active
July 8, 2020 10:08
-
-
Save alexanderadam/00f40186d2797cfb9b1dffdc78dac445 to your computer and use it in GitHub Desktop.
Properly debug Jekyll variables
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
--- | |
layout: page | |
title: debug | |
permalink: /debug | |
--- | |
<div id="jekyll-debug"></div> | |
<script> | |
var debugDiv = document.getElementById('jekyll-debug'); | |
{% assign debug_variables = "site, page, layout, content, paginator" | split: ',' %} | |
var variables = { | |
{% for var in debug_variables %} | |
"{{ var }}": JSON.stringify(JSON.parse(decodeURIComponent("{{ [var] | jsonify | uri_escape }}")), null, 2), | |
{% endfor %} | |
}; | |
for (var key in variables) { | |
var variableDiv = document.createElement('pre'); | |
variableDiv.textContent = key + ":\n" + variables[key] + "\n"; | |
document.body.appendChild(variableDiv); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting
Liquid Warning: Liquid syntax error (line 8): [:open_square, "["] is not a valid expression in "{{ [var] | jsonify | uri_escape }}"
but it seems to work anyway.