Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a {% debug %} extension tag. #983

Merged
merged 3 commits into from
Oct 5, 2019

Conversation

kevin-brown
Copy link
Member

@kevin-brown kevin-brown commented May 6, 2019

Cloned from #798 and rebased with latest master.


This dumps the available variables, filters and tests. See Issue #174.
This is roughly equivalent to the Django Template Language {% debug %} tag, and typical usage like this:

{% debug %}

produces output like this:

{'context': {'_': <function _gettext_alias at 0x7f9ceabde488>,
            'csrf_token': <SimpleLazyObject: 'lfPE7al...q3bykS4txKfb3'>,
            'cycler': <class 'jinja2.utils.Cycler'>,
            ...
            'view': <polls.views_auth.Login object at 0x7f9cea2cbe48>},
'filters': ['abs', 'add', 'addslashes', 'attr', 'batch', 'bootstrap',
            'bootstrap_classes', 'bootstrap_horizontal',
            'bootstrap_inline', ... 'yesno'],
'tests': ['callable', 'checkbox_field', 'defined', 'divisibleby',
        'escaped', 'even', 'iterable', 'lower', 'mapping',
        'multiple_checkbox_field', ... 'string', 'undefined', 'upper']}

The output under Python2 and Python3 below 3.4 is slightly less compact, as pprint.format() did not introduce the 'compact' argument before 3.4.


/cc @ShaheedHaque

This dumps the available variables, filters and tests.
@davidism
Copy link
Member

davidism commented Oct 5, 2019

Changed to rely on autoescape rather than calling escape unconditionally. This way it's usable outside HTML.

Rebased and added docs and changelog.

@davidism davidism merged commit 3ea88fe into pallets:master Oct 5, 2019
@kevin-brown kevin-brown deleted the pr/798 branch October 10, 2019 00:23
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants