class documentation

class NativeEnvironment(Environment): (source)

View In Hierarchy

An environment that renders templates to native Python types.

Class Variable concat Undocumented

Inherited from Environment:

Method __init__ Undocumented
Method add_extension Adds an extension after the environment was created.
Method call_filter Invoke a filter on a value the same way the compiler does.
Method call_test Invoke a test on a value the same way the compiler does.
Method compile Compile a node or template source code. The `name` parameter is the load name of the template after it was joined using :meth:`join_path` if necessary, not the filename on the file system. the `filename` parameter is the estimated filename of the template on the file system...
Method compile_expression A handy helper method that returns a callable that accepts keyword arguments that appear as variables in the expression. If called it returns the result of the expression.
Method compile_templates Finds all the templates the loader can find, compiles them and stores them in `target`. If `zip` is `None`, instead of in a zipfile, the templates will be stored in a directory. By default a deflate zip algorithm is used...
Method extend Add the items to the instance of the environment if they do not exist yet. This is used by :ref:`extensions <writing-extensions>` to register callbacks and configuration values without breaking inheritance.
Method from_string Load a template from a source string without using :attr:`loader`.
Method get_or_select_template Use :meth:`select_template` if an iterable of template names is given, or :meth:`get_template` if one name is given.
Method get_template Load a template by name with :attr:`loader` and return a :class:`Template`. If the template does not exist a :exc:`TemplateNotFound` exception is raised.
Method getattr Get an item or attribute of an object but prefer the attribute. Unlike :meth:`getitem` the attribute *must* be a string.
Method getitem Get an item or attribute of an object but prefer the item.
Method handle_exception Exception handling helper. This is used internally to either raise rewritten exceptions or return a rendered traceback for the template.
Method iter_extensions Iterates over the extensions by priority.
Method join_path Join a template with the parent. By default all the lookups are relative to the loader root so this method returns the `template` parameter unchanged, but if the paths should be relative to the parent template, this function can be used to calculate the real template name.
Method lex Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development <writing-extensions>` and debugging templates.
Method list_templates Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method.
Method make_globals Make the globals map for a template. Any given template globals overlay the environment :attr:`globals`.
Method overlay Create a new overlay environment that shares all the data with the current environment except for cache and the overridden attributes. Extensions cannot be removed for an overlayed environment. An overlayed environment automatically gets all the extensions of the environment it is linked to plus optional extra extensions.
Method parse Parse the sourcecode and return the abstract syntax tree. This tree of nodes is used by the compiler to convert the template into executable source- or bytecode. This is useful for debugging or to extract information from templates.
Method preprocess Preprocesses the source with all extensions. This is automatically called for all parsing and compiling methods but *not* for :meth:`lex` because there you usually only want the actual source tokenized.
Method select_template Like :meth:`get_template`, but tries loading multiple names. If none of the names can be loaded a :exc:`TemplatesNotFound` exception is raised.
Class Variable linked_to Undocumented
Class Variable overlayed Undocumented
Class Variable sandboxed Undocumented
Class Variable shared Undocumented
Class Variable template_class Undocumented
Instance Variable auto_reload Undocumented
Instance Variable autoescape Undocumented
Instance Variable block_end_string Undocumented
Instance Variable block_start_string Undocumented
Instance Variable bytecode_cache Undocumented
Instance Variable cache Undocumented
Instance Variable comment_end_string Undocumented
Instance Variable comment_start_string Undocumented
Instance Variable extensions Undocumented
Instance Variable filters Undocumented
Instance Variable finalize Undocumented
Instance Variable globals Undocumented
Instance Variable is_async Undocumented
Instance Variable keep_trailing_newline Undocumented
Instance Variable line_comment_prefix Undocumented
Instance Variable line_statement_prefix Undocumented
Instance Variable loader Undocumented
Instance Variable lstrip_blocks Undocumented
Instance Variable newline_sequence Undocumented
Instance Variable optimized Undocumented
Instance Variable policies Undocumented
Instance Variable tests Undocumented
Instance Variable trim_blocks Undocumented
Instance Variable undefined Undocumented
Instance Variable variable_end_string Undocumented
Instance Variable variable_start_string Undocumented
Property lexer The lexer for this environment.
Method _compile Internal hook that can be overridden to hook a different compile method in.
Method _filter_test_common Undocumented
Method _generate Internal hook that can be overridden to hook a different generate method in.
Method _load_template Undocumented
Method _parse Internal parsing function used by `parse` and `compile`.
Method _tokenize Called by the parser to do the preprocessing and filtering for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`.