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
Merged

Conversation

@kevin-brown
Copy link
Collaborator

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 davidism force-pushed the kevin-brown:pr/798 branch from 9f2a435 to bf68e90 Oct 4, 2019
@davidism davidism added this to the 2.11.0 milestone Oct 5, 2019
@davidism davidism force-pushed the kevin-brown:pr/798 branch from bf68e90 to 9728aae Oct 5, 2019
davidism added 2 commits Oct 5, 2019
@davidism davidism force-pushed the kevin-brown:pr/798 branch from 9728aae to 5e645ab Oct 5, 2019
@davidism

This comment has been minimized.

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
10 checks passed
10 checks passed
Tests Build #20191005.2 succeeded
Details
Tests (Job Docs) Job Docs succeeded
Details
Tests (Job PyPy 3 Linux) Job PyPy 3 Linux succeeded
Details
Tests (Job Python 2.7 Linux) Job Python 2.7 Linux succeeded
Details
Tests (Job Python 2.7 Windows) Job Python 2.7 Windows succeeded
Details
Tests (Job Python 3.5 Linux) Job Python 3.5 Linux succeeded
Details
Tests (Job Python 3.6 Linux) Job Python 3.6 Linux succeeded
Details
Tests (Job Python 3.7 Linux) Job Python 3.7 Linux succeeded
Details
Tests (Job Python 3.7 Mac) Job Python 3.7 Mac succeeded
Details
Tests (Job Python 3.7 Windows) Job Python 3.7 Windows succeeded
Details
@kevin-brown kevin-brown deleted the kevin-brown:pr/798 branch Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.