Created
January 26, 2018 16:24
-
-
Save hvgab/050e4e33f16c8b8939d02f39aa0ca164 to your computer and use it in GitHub Desktop.
Add a json prettyprint filter for jinja
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
# prettyprint json i jinja | |
def ppjson(value, indent=2): | |
return json.dumps(value, indent=indent) | |
jinja2.filters.FILTERS['ppjson'] = ppjson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is also a built-in one:
{{ foo | tojson(2) }}