Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
jinja2.loaders.PackageLoader Class Reference
Inheritance diagram for jinja2.loaders.PackageLoader:
Inheritance graph
[legend]
Collaboration diagram for jinja2.loaders.PackageLoader:
Collaboration graph
[legend]

Public Member Functions

None __init__ (self, str package_name, "str" package_path="templates", str encoding="utf-8")
 
t.Tuple[str, str, t.Optional[t.Callable[[], bool]]] get_source (self, "Environment" environment, str template)
 
t.List[str] list_templates (self)
 
- Public Member Functions inherited from jinja2.loaders.BaseLoader
"Template" load (self, "Environment" environment, str name, t.Optional[t.MutableMapping[str, t.Any]] globals=None)
 

Public Attributes

 package_path
 
 package_name
 
 encoding
 

Protected Attributes

 _loader
 
 _archive
 
 _template_root
 

Additional Inherited Members

- Static Public Attributes inherited from jinja2.loaders.BaseLoader
bool has_source_access = True
 

Detailed Description

Load templates from a directory in a Python package.

:param package_name: Import name of the package that contains the
    template directory.
:param package_path: Directory within the imported package that
    contains the templates.
:param encoding: Encoding of template files.

The following example looks up templates in the ``pages`` directory
within the ``project.ui`` package.

.. code-block:: python

    loader = PackageLoader("project.ui", "pages")

Only packages installed as directories (standard pip behavior) or
zip/egg files (less common) are supported. The Python API for
introspecting data in packages is too limited to support other
installation methods the way this loader requires.

There is limited support for :pep:`420` namespace packages. The
template directory is assumed to only be in one namespace
contributor. Zip files contributing to a namespace are not
supported.

.. versionchanged:: 3.0
    No longer uses ``setuptools`` as a dependency.

.. versionchanged:: 3.0
    Limited PEP 420 namespace package support.

Member Function Documentation

◆ get_source()

t.Tuple[str, str, t.Optional[t.Callable[[], bool]]] jinja2.loaders.PackageLoader.get_source (   self,
"Environment"  environment,
str   template 
)
Get the template source, filename and reload helper for a template.
It's passed the environment and template name and has to return a
tuple in the form ``(source, filename, uptodate)`` or raise a
`TemplateNotFound` error if it can't locate the template.

The source part of the returned tuple must be the source of the
template as a string. The filename should be the name of the
file on the filesystem if it was loaded from there, otherwise
``None``. The filename is used by Python for the tracebacks
if no loader extension is used.

The last item in the tuple is the `uptodate` function.  If auto
reloading is enabled it's always called to check if the template
changed.  No arguments are passed so the function must store the
old state somewhere (for example in a closure).  If it returns `False`
the template will be reloaded.

Reimplemented from jinja2.loaders.BaseLoader.

◆ list_templates()

t.List[str] jinja2.loaders.PackageLoader.list_templates (   self)
Iterates over all templates.  If the loader does not support that
it should raise a :exc:`TypeError` which is the default behavior.

Reimplemented from jinja2.loaders.BaseLoader.


The documentation for this class was generated from the following file: