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
>>> 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``.
.. code:: python
>>> 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/ondratu/jinja2-template-info",
"name": "Jinja2-template-info",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Ond\u0159ej T\u016fma",
"author_email": "mcbig@zeropage.cz",
"download_url": "https://files.pythonhosted.org/packages/35/85/53936720422595cb8cd25b9cf6344b1030c0095faef7b5ef85e138d75609/Jinja2-template_info-0.2.4.tar.gz",
"platform": null,
"description": "Jinja2 template info\n====================\n\nJinja2-template_info is Jinja2 Extension module and piece of code to generate\nand show some template information which could help with debuging templates.\n\n``template_info``\n-----------------\n\n``render(template, path, **kwargs)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nThat is simple function, which return rendered string from Jinja2. If there is\n``debug`` variable set to positive variable in ``kawrgs``,\n``TemplateInfoExtension`` is used and attributes ``data`` and ``template`` was\nset.\n\n:template: template file name\n:path: path or paths, where jinja could find the template\n:\\**kwargs: data, which are send to template\n\n\n.. code:: python\n\n >>> try:\n ... from importlib.resources import files\n ... except ImportError:\n ... from importlib_resources import files\n >>> from jinja2_template_info import render\n >>> path = (files('jinja2_template_info'), \"./\")\n >>> render(\"test.html\", path, debug=True,\n ... code_variable=\"Variable from code\")\n ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n '<!DOCTYPE html>...</html>'\n\n\n``class TemplateInfoExtension(Extension)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nExtension class, which append ``TemplateInfo`` instance to template in\n``template_info`` variable. This class contains own ``Undefined`` class, which\nis use to store undefined variables names. They are in\n``template_info.undefined``.\n\n.. code:: python\n\n >>> try:\n ... from importlib.resources import files\n ... except ImportError:\n ... from importlib_resources import files\n >>> from jinja2 import Environment, FileSystemLoader\n >>> from jinja2_template_info import TemplateInfoExtension\n >>> data = {\"title\":\"Title\"}\n >>> path = (files('jinja2_template_info'), \"./\")\n >>> env = Environment(loader=FileSystemLoader(path),\n ... extensions=[TemplateInfoExtension])\n >>> env.globals[\"template_info\"].data = data.copy()\n >>> env.globals[\"template_info\"].template = \"test.html\"\n >>> template = env.get_template(\"test.html\")\n >>> template.render(data) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n '<!DOCTYPE html>...</html>'\n\n``template_info.html``\n----------------------\nThis file contains some macros for better html output of variables. Becouse\nlocal template variables are readed only from each template, that must be\nused as macro argument.\n\n``render_info(local_variables=none)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nAppend debug output to template. Output is labeled with section name, some\nsections are shown only if they are set.\n\n:Local Variables:\n Variables from template, where render_info is call. Local\n variable could be get with\n ``template_info.context().get_exported())`` call.\n:Template: Template file name (``template_info`` variable).\n:Input Variables:\n kwargs data from ``render`` function (``template_info`` variable).\n:Context: Context content without variables. There are all functions, macros\n and other objects set to ``environment.globals``.\n:Undefined objects:\n List of undefined variables,functions, macros and other objects,\n which is not found and template want use it.\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Jinja2 Extension for template debugging.",
"version": "0.2.4",
"project_urls": {
"Homepage": "https://github.com/ondratu/jinja2-template-info"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2065748346e6ba55e9febb9d1884a3b9052d3ad49c031e404397b7a8e09ccfd2",
"md5": "7a590a2f3b71de17d9705cccd029aaad",
"sha256": "82a44c7eb65fb2322eb611ddc2a2575a3add961bd03ca44831f1622ca474fde2"
},
"downloads": -1,
"filename": "Jinja2_template_info-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7a590a2f3b71de17d9705cccd029aaad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10328,
"upload_time": "2022-03-30T07:18:22",
"upload_time_iso_8601": "2022-03-30T07:18:22.081636Z",
"url": "https://files.pythonhosted.org/packages/20/65/748346e6ba55e9febb9d1884a3b9052d3ad49c031e404397b7a8e09ccfd2/Jinja2_template_info-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "358553936720422595cb8cd25b9cf6344b1030c0095faef7b5ef85e138d75609",
"md5": "5f106aa622adbb47eefb48a649a44d81",
"sha256": "e5cff658f68efd97d976b8c42e6aa3213a8b763e50081677db0909bbb6560b62"
},
"downloads": -1,
"filename": "Jinja2-template_info-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "5f106aa622adbb47eefb48a649a44d81",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5812,
"upload_time": "2022-03-30T07:18:23",
"upload_time_iso_8601": "2022-03-30T07:18:23.748544Z",
"url": "https://files.pythonhosted.org/packages/35/85/53936720422595cb8cd25b9cf6344b1030c0095faef7b5ef85e138d75609/Jinja2-template_info-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-03-30 07:18:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ondratu",
"github_project": "jinja2-template-info",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "jinja2-template-info"
}