class documentation

class NativeTemplate(Template): (source)

View In Hierarchy

Undocumented

Method render Render the template to produce a native Python type. If the result is a single node, its value is returned. Otherwise, the nodes are concatenated as strings. If the result can be parsed with :func:`ast...
Async Method render_async 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.

Inherited from Template:

Class Method from_code Creates a template object from compiled code and the globals. This is used by the loaders and environment to create a template object.
Class Method from_module_dict Creates a template object from a module. This is used by the module loader to create a template object.
Method __new__ Undocumented
Method __repr__ Undocumented
Method generate 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.
Async Method generate_async An async version of :meth:`generate`. Works very similarly but returns an async iterator instead.
Method get_corresponding_lineno Return the source line number of a line number in the generated bytecode as they are not in sync.
Method make_module 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...
Async Method make_module_async 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.
Method new_context 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.
Method stream Works exactly like :meth:`generate` but returns a :class:`TemplateStream`.
Class Variable blocks Undocumented
Class Variable environment Undocumented
Class Variable filename Undocumented
Class Variable globals Undocumented
Class Variable name Undocumented
Class Variable root_render_func Undocumented
Property debug_info The debug info mapping.
Property is_up_to_date If this variable is `False` there is a newer version available.
Property module 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:
Class Method _from_namespace Undocumented
Method _get_default_module 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.
Async Method _get_default_module_async Undocumented
Class Variable _debug_info Undocumented
Class Variable _uptodate Undocumented
Instance Variable _module Undocumented
def render(self, *args, **kwargs): (source)

Render the template to produce a native Python type. If the result is a single node, its value is returned. Otherwise, the nodes are concatenated as strings. If the result can be parsed with :func:`ast.literal_eval`, the parsed value is returned. Otherwise, the string is returned.

Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
t.AnyUndocumented
async def render_async(self, *args, **kwargs): (source)

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

Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
t.AnyUndocumented