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

Public Member Functions

None __init__ (self, t.Mapping[str, BaseLoader] mapping, str delimiter="/")
 
t.Tuple[BaseLoader, str] get_loader (self, str template)
 
t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]] get_source (self, "Environment" environment, str template)
 
"Template" load (self, "Environment" environment, str name, t.Optional[t.MutableMapping[str, t.Any]] globals=None)
 
t.List[str] list_templates (self)
 

Public Attributes

 mapping
 
 delimiter
 

Additional Inherited Members

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

Detailed Description

A loader that is passed a dict of loaders where each loader is bound
to a prefix.  The prefix is delimited from the template by a slash per
default, which can be changed by setting the `delimiter` argument to
something else::

    loader = PrefixLoader({
        'app1':     PackageLoader('mypackage.app1'),
        'app2':     PackageLoader('mypackage.app2')
    })

By loading ``'app1/index.html'`` the file from the app1 package is loaded,
by loading ``'app2/index.html'`` the file from the second.

Member Function Documentation

◆ get_source()

t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]] jinja2.loaders.PrefixLoader.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.PrefixLoader.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.

◆ load()

"Template" jinja2.loaders.PrefixLoader.load (   self,
"Environment"  environment,
str  name,
t.Optional[t.MutableMapping[str, t.Any]]   globals = None 
)
Loads a template.  This method looks up the template in the cache
or loads one by calling :meth:`get_source`.  Subclasses should not
override this method as loaders working on collections of other
loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
will not call this method but `get_source` directly.

Reimplemented from jinja2.loaders.BaseLoader.


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