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

Public Member Functions

t.Any __new__ (cls, t.Union[str, nodes.Template] source, str block_start_string=BLOCK_START_STRING, str block_end_string=BLOCK_END_STRING, str variable_start_string=VARIABLE_START_STRING, str variable_end_string=VARIABLE_END_STRING, str comment_start_string=COMMENT_START_STRING, str comment_end_string=COMMENT_END_STRING, t.Optional[str] line_statement_prefix=LINE_STATEMENT_PREFIX, t.Optional[str] line_comment_prefix=LINE_COMMENT_PREFIX, bool trim_blocks=TRIM_BLOCKS, bool lstrip_blocks=LSTRIP_BLOCKS, "te.Literal['\\n', '\\r\\n', '\\r']" newline_sequence=NEWLINE_SEQUENCE, bool keep_trailing_newline=KEEP_TRAILING_NEWLINE, t.Sequence[t.Union[str, t.Type["Extension"]]] extensions=(), bool optimized=True, t.Type[Undefined] undefined=Undefined, t.Optional[t.Callable[..., t.Any]] finalize=None, t.Union[bool, t.Callable[[t.Optional[str]], bool]] autoescape=False, bool enable_async=False)
 
"Template" from_code (cls, Environment environment, CodeType code, t.MutableMapping[str, t.Any] globals, t.Optional[t.Callable[[], bool]] uptodate=None)
 
"Template" from_module_dict (cls, Environment environment, t.MutableMapping[str, t.Any] module_dict, t.MutableMapping[str, t.Any] globals)
 
str render (self, *t.Any args, **t.Any kwargs)
 
str render_async (self, *t.Any args, **t.Any kwargs)
 
"TemplateStream" stream (self, *t.Any args, **t.Any kwargs)
 
t.Iterator[str] generate (self, *t.Any args, **t.Any kwargs)
 
t.AsyncGenerator[str, object] generate_async (self, *t.Any args, **t.Any kwargs)
 
Context new_context (self, t.Optional[t.Dict[str, t.Any]] vars=None, bool shared=False, t.Optional[t.Mapping[str, t.Any]] locals=None)
 
"TemplateModule" make_module (self, t.Optional[t.Dict[str, t.Any]] vars=None, bool shared=False, t.Optional[t.Mapping[str, t.Any]] locals=None)
 
"TemplateModule" make_module_async (self, t.Optional[t.Dict[str, t.Any]] vars=None, bool shared=False, t.Optional[t.Mapping[str, t.Any]] locals=None)
 
"TemplateModule" module (self)
 
int get_corresponding_lineno (self, int lineno)
 
bool is_up_to_date (self)
 
t.List[t.Tuple[int, int]] debug_info (self)
 
str __repr__ (self)
 

Public Attributes

 environment_class
 
 environment
 
 name
 
 blocks
 
 globals
 
 debug_info
 

Static Public Attributes

environment_class = Environment
 
Environment environment
 
globals .MutableMapping[str, t.Any]
 
name .Optional[str]
 
filename .Optional[str]
 
blocks .Dict[str, t.Callable[[Context], t.Iterator[str]]]
 
root_render_func .Callable[[Context], t.Iterator[str]]
 

Protected Member Functions

"Template" _from_namespace (cls, Environment environment, t.MutableMapping[str, t.Any] namespace, t.MutableMapping[str, t.Any] globals)
 
"TemplateModule" _get_default_module (self, t.Optional[Context] ctx=None)
 
"TemplateModule" _get_default_module_async (self, t.Optional[Context] ctx=None)
 

Protected Attributes

 _module
 

Static Protected Attributes

_module .Optional["TemplateModule"]
 
str _debug_info
 
_uptodate .Optional[t.Callable[[], bool]]
 

Detailed Description

A compiled template that can be rendered.

Use the methods on :class:`Environment` to create or load templates.
The environment is used to configure how templates are compiled and
behave.

It is also possible to create a template object directly. This is
not usually recommended. The constructor takes most of the same
arguments as :class:`Environment`. All templates created with the
same environment arguments share the same ephemeral ``Environment``
instance behind the scenes.

A template object should be considered immutable. Modifications on
the object are not supported.

Member Function Documentation

◆ _get_default_module()

"TemplateModule" jinja2.environment.Template._get_default_module (   self,
t.Optional[Context]   ctx = None 
)
protected
If a context is passed in, this means that the template was
imported. Imported templates have access to the current
template's globals by default, but they can only be accessed via
the context during runtime.

If there are new globals, we need to create a new module because
the cached module is already rendered and will not have access
to globals from the current context. This new module is not
cached because the template can be imported elsewhere, and it
should have access to only the current template's globals.

◆ debug_info()

t.List[t.Tuple[int, int]] jinja2.environment.Template.debug_info (   self)
The debug info mapping.

◆ from_code()

"Template" jinja2.environment.Template.from_code (   cls,
Environment  environment,
CodeType  code,
t.MutableMapping[str, t.Any]  globals,
t.Optional[t.Callable[[], bool]]   uptodate = None 
)
Creates a template object from compiled code and the globals.  This
is used by the loaders and environment to create a template object.

◆ from_module_dict()

"Template" jinja2.environment.Template.from_module_dict (   cls,
Environment  environment,
t.MutableMapping[str, t.Any]  module_dict,
t.MutableMapping[str, t.Any]  globals 
)
Creates a template object from a module.  This is used by the
module loader to create a template object.

.. versionadded:: 2.4

◆ generate()

t.Iterator[str] jinja2.environment.Template.generate (   self,
*t.Any  args,
**t.Any  kwargs 
)
For very large templates it can be useful to not render the whole
template at once but evaluate each statement after another and yield
piece for piece.  This method basically does exactly that and returns
a generator that yields one item after another as strings.

It accepts the same arguments as :meth:`render`.

◆ generate_async()

t.AsyncGenerator[str, object] jinja2.environment.Template.generate_async (   self,
*t.Any  args,
**t.Any   kwargs 
)
An async version of :meth:`generate`.  Works very similarly but
returns an async iterator instead.

◆ get_corresponding_lineno()

int jinja2.environment.Template.get_corresponding_lineno (   self,
int  lineno 
)
Return the source line number of a line number in the
generated bytecode as they are not in sync.

◆ is_up_to_date()

bool jinja2.environment.Template.is_up_to_date (   self)
If this variable is `False` there is a newer version available.

◆ make_module()

"TemplateModule" jinja2.environment.Template.make_module (   self,
t.Optional[t.Dict[str, t.Any]]   vars = None,
bool   shared = False,
t.Optional[t.Mapping[str, t.Any]]   locals = None 
)
This method works like the :attr:`module` attribute when called
without arguments but it will evaluate the template on every call
rather than caching it.  It's also possible to provide
a dict which is then used as context.  The arguments are the same
as for the :meth:`new_context` method.

◆ make_module_async()

"TemplateModule" jinja2.environment.Template.make_module_async (   self,
t.Optional[t.Dict[str, t.Any]]   vars = None,
bool   shared = False,
t.Optional[t.Mapping[str, t.Any]]   locals = None 
)
As template module creation can invoke template code for
asynchronous executions this method must be used instead of the
normal :meth:`make_module` one.  Likewise the module attribute
becomes unavailable in async mode.

◆ module()

"TemplateModule" jinja2.environment.Template.module (   self)
The template as module.  This is used for imports in the
template runtime but is also useful if one wants to access
exported template variables from the Python layer:

>>> t = Template('{% macro foo() %}42{% endmacro %}23')
>>> str(t.module)
'23'
>>> t.module.foo() == u'42'
True

This attribute is not available if async mode is enabled.

◆ new_context()

Context jinja2.environment.Template.new_context (   self,
t.Optional[t.Dict[str, t.Any]]   vars = None,
bool   shared = False,
t.Optional[t.Mapping[str, t.Any]]   locals = None 
)
Create a new :class:`Context` for this template.  The vars
provided will be passed to the template.  Per default the globals
are added to the context.  If shared is set to `True` the data
is passed as is to the context without adding the globals.

`locals` can be a dict of local variables for internal usage.

◆ render()

str jinja2.environment.Template.render (   self,
*t.Any  args,
**t.Any  kwargs 
)
This method accepts the same arguments as the `dict` constructor:
A dict, a dict subclass or some keyword arguments.  If no arguments
are given the context will be empty.  These two calls do the same::

    template.render(knights='that say nih')
    template.render({'knights': 'that say nih'})

This will return the rendered template as a string.

Reimplemented in jinja2.nativetypes.NativeTemplate.

◆ render_async()

str jinja2.environment.Template.render_async (   self,
*t.Any  args,
**t.Any  kwargs 
)
This works similar to :meth:`render` but returns a coroutine
that when awaited returns the entire rendered template string.  This
requires the async feature to be enabled.

Example usage::

    await template.render_async(knights='that say nih; asynchronously')

Reimplemented in jinja2.nativetypes.NativeTemplate.

◆ stream()

"TemplateStream" jinja2.environment.Template.stream (   self,
*t.Any  args,
**t.Any  kwargs 
)
Works exactly like :meth:`generate` but returns a
:class:`TemplateStream`.

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