Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ondratu/jinja2-template-info

Simple code, which generate tempate_info to output with Jinja2.
https://github.com/ondratu/jinja2-template-info

Last synced: 3 months ago
JSON representation

Simple code, which generate tempate_info to output with Jinja2.

Awesome Lists containing this project

README

        

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
'...