Skip to main content

Jinja2 filters to expose Context and Environment values to templates.

Project description

Jinja2 Context Filters

Overview

This Jinja2 Extension plugin provides filters that expose introspection values about the current Jinja2 Context and Environment objects for the current template's Environment().

Included filters

  • context_info
    • blocks(available blocks defined in this or a parent template)
    • exported(vars exported from this template)
    • global_vars(vars passed in to render)
    • name(name of the current template object... often the template filename)
    • vars(vars declared with set both here or from a parent)
  • environment_info
    • extensions
    • filters
    • tests

Install

pip install jinja2-context-filters

Usage

Typical usage with jinja2

  from jinja2 import Environment

...
  env = Environment(extensions=['jinja2_context_filters.Jinja2ContextExtension'])
...
# OR
  from jinja2_context_filters import Jinja2ContextExtension
  env = Environment(extensions=[Jinja2ContextExtension])
...

In a template

{{ 'name' | context_info }}
{{ 'blocks' | context_info }}
{{ 'exported' | context_info }}
{{ 'filters' | environment_info }}
{{ 'tests' | environment_info }}
{{ 'extensions' | environment_info }}

Include into cookiecutter

cookiecutter.json

{
  "_extensions": ["jinja2_context_filters.Jinja2ContextExtension"]
}

License

MIT License

1.0.0 (2019-11-15)

Bug Fixes

  • Fixed setup.cfg by removing quotes from desc (ae45723)

Features

  • Added vars and global vars + tests 100% (677ca37)

MIT License

Copyright (c) 2019 Global InfoTek, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jinja2-context-filters-1.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinja2_context_filters-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file jinja2-context-filters-1.0.0.tar.gz.

File metadata

  • Download URL: jinja2-context-filters-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for jinja2-context-filters-1.0.0.tar.gz
Algorithm Hash digest
SHA256 08172b1c4c7f834aadf39635af983948faa792fa30480e9f00a7356464dea60d
MD5 56d57da12368dd8fbbf6a1b2c2d40d93
BLAKE2b-256 03fdf97f996dd9cce006edab819d2e59c887e5f1411f7a70b24304f8fc7bfc17

See more details on using hashes here.

File details

Details for the file jinja2_context_filters-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: jinja2_context_filters-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for jinja2_context_filters-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d33922756b548600a69a95f8279bc99b802a6b9fde35abfe463d3750e8812a69
MD5 edb3dcc4224bf289992f1fb0fe3fd731
BLAKE2b-256 b3ad78ad63623c82584030d73b57447625b61b2986f2854f701cf9a739510639

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page