Skip to main content

Jinja2 template info

Jinja2-template_info is Jinja2 Extension module and piece of code to generate and show some template information which could help with debuging templates.

template_info

render(template, path, **kwargs)

That is simple function, which return rendered string from Jinja2. If there is debug variable set to positive variable in kawrgs, TemplateInfoExtension is used and attributes data and template was set.

template:

template file name

path:

path or paths, where jinja could find the template

**kwargs:

data, which are send to template

>>> try:
...     from importlib.resources import files
... except ImportError:
...     from importlib_resources import files
>>> from jinja2_template_info import render
>>> path = (files('jinja2_template_info'), "./")
>>> render("test.html", path, debug=True,
...        code_variable="Variable from code")
...        # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
'<!DOCTYPE html>...</html>'

class TemplateInfoExtension(Extension)

Extension class, which append TemplateInfo instance to template in template_info variable. This class contains own Undefined class, which is use to store undefined variables names. They are in template_info.undefined.

>>> try:
...     from importlib.resources import files
... except ImportError:
...     from importlib_resources import files
>>> from jinja2 import Environment, FileSystemLoader
>>> from jinja2_template_info import TemplateInfoExtension
>>> data = {"title":"Title"}
>>> path = (files('jinja2_template_info'), "./")
>>> env = Environment(loader=FileSystemLoader(path),
...                   extensions=[TemplateInfoExtension])
>>> env.globals["template_info"].data = data.copy()
>>> env.globals["template_info"].template = "test.html"
>>> template = env.get_template("test.html")
>>> template.render(data)   # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
'<!DOCTYPE html>...</html>'

template_info.html

This file contains some macros for better html output of variables. Becouse local template variables are readed only from each template, that must be used as macro argument.

render_info(local_variables=none)

Append debug output to template. Output is labeled with section name, some sections are shown only if they are set.

Local Variables:

Variables from template, where render_info is call. Local variable could be get with template_info.context().get_exported()) call.

Template:

Template file name (template_info variable).

Input Variables:

kwargs data from render function (template_info variable).

Context:

Context content without variables. There are all functions, macros and other objects set to environment.globals.

Undefined objects:

List of undefined variables,functions, macros and other objects, which is not found and template want use it.

Metadata

Release files for Jinja2-template-info 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Jinja2-template-info 0.2.4
File Size Uploaded
Jinja2-template_info-0.2.4.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Jinja2-template-info 0.2.4
File Interpreter ABI Platform
Jinja2_template_info-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / Jinja2-template_info-0.2.4.tar.gz

Download URL Jinja2-template_info-0.2.4.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e5cff658f68efd97d976b8c42e6aa3213a8b763e50081677db0909bbb6560b62
BLAKE2b-256 checksum
How to use checksums
358553936720422595cb8cd25b9cf6344b1030c0095faef7b5ef85e138d75609
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.5

Release files / Jinja2_template_info-0.2.4-py3-none-any.whl

Download URL Jinja2_template_info-0.2.4-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82a44c7eb65fb2322eb611ddc2a2575a3add961bd03ca44831f1622ca474fde2
BLAKE2b-256 checksum
How to use checksums
2065748346e6ba55e9febb9d1884a3b9052d3ad49c031e404397b7a8e09ccfd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

3 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page