Jinja2 Extension for template debugging.
Project description
>>> from jinja2_template_info import render
>>> render("test.html", "./", debug=True,
... code_variable="Variable from code")
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
'<!DOCTYPE html>...</html>'
Home-page: https://github.com/ondratu/jinja2-template-info
Author: Ondřej Tůma
Author-email: mcbig@zeropage.cz
License: BSD
Description: 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
.. code:: python
>>> from jinja2_template_info import render
>>> render("test.html", "./", 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``.
.. code:: python
>>> from jinja2 import Environment, FileSystemLoader
>>> from jinja2_template_info import TemplateInfoExtension
>>> data = {"title":"Title"}
>>> env = Environment(loader=FileSystemLoader("./"),
... 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.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/x-rst
>>> render("test.html", "./", debug=True,
... code_variable="Variable from code")
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
'<!DOCTYPE html>...</html>'
Home-page: https://github.com/ondratu/jinja2-template-info
Author: Ondřej Tůma
Author-email: mcbig@zeropage.cz
License: BSD
Description: 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
.. code:: python
>>> from jinja2_template_info import render
>>> render("test.html", "./", 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``.
.. code:: python
>>> from jinja2 import Environment, FileSystemLoader
>>> from jinja2_template_info import TemplateInfoExtension
>>> data = {"title":"Title"}
>>> env = Environment(loader=FileSystemLoader("./"),
... 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.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/x-rst
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
Built Distributions
File details
Details for the file Jinja2-template_info-0.1.0.tar.gz
.
File metadata
- Download URL: Jinja2-template_info-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae93d568e1ff4612ea7d76a2d6d6f57d9c1657165b8b8876aa647bde4e7ac569 |
|
MD5 | 6ba8bc3837f31c5dec95145921f7bd7b |
|
BLAKE2b-256 | 29ec5af7acfdf6d1d0e5f315c5cb4f00629fbc18266f52e0642d97d7957fb02b |
File details
Details for the file Jinja2_template_info-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: Jinja2_template_info-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 252f0bff8a52c51325a96bd747f538f7f4b8e9762baaa1de4479bb4aa8696612 |
|
MD5 | 48b5fb7dcf66e61dde2d25258965019e |
|
BLAKE2b-256 | 928b527e20578804912aae673402991ff76ecd83e8f2cadef51e365feae3824f |
File details
Details for the file Jinja2_template_info-0.1.0-py2-none-any.whl
.
File metadata
- Download URL: Jinja2_template_info-0.1.0-py2-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d015b9ed1e7dfb1d0452ca2077bbfc1bc9745d8464dff155f7f1e55e4e2db5 |
|
MD5 | 1dd2cc329bc7a196dcb0cad4dc305ade |
|
BLAKE2b-256 | f144a33d20fce4225e204ae21f2dc83103e69a7c4a072b995546d0bc2daf492d |