class documentation
class NativeEnvironment(Environment): (source)
An environment that renders templates to native Python types.
Class Variable | concat |
Undocumented |
Inherited from Environment
:
Method | __init__ |
Undocumented |
Method | add |
Adds an extension after the environment was created. |
Method | call |
Invoke a filter on a value the same way the compiler does. |
Method | call |
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 |
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 |
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 |
Load a template from a source string without using :attr:`loader`. |
Method | get |
Use :meth:`select_template` if an iterable of template names is given, or :meth:`get_template` if one name is given. |
Method | get |
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 handling helper. This is used internally to either raise rewritten exceptions or return a rendered traceback for the template. |
Method | iter |
Iterates over the extensions by priority. |
Method | join |
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 |
Returns a list of templates for this environment. This requires that the loader supports the loader's :meth:`~BaseLoader.list_templates` method. |
Method | make |
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 |
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 |
Undocumented |
Class Variable | overlayed |
Undocumented |
Class Variable | sandboxed |
Undocumented |
Class Variable | shared |
Undocumented |
Class Variable | template |
Undocumented |
Instance Variable | auto |
Undocumented |
Instance Variable | autoescape |
Undocumented |
Instance Variable | block |
Undocumented |
Instance Variable | block |
Undocumented |
Instance Variable | bytecode |
Undocumented |
Instance Variable | cache |
Undocumented |
Instance Variable | comment |
Undocumented |
Instance Variable | comment |
Undocumented |
Instance Variable | extensions |
Undocumented |
Instance Variable | filters |
Undocumented |
Instance Variable | finalize |
Undocumented |
Instance Variable | globals |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | keep |
Undocumented |
Instance Variable | line |
Undocumented |
Instance Variable | line |
Undocumented |
Instance Variable | loader |
Undocumented |
Instance Variable | lstrip |
Undocumented |
Instance Variable | newline |
Undocumented |
Instance Variable | optimized |
Undocumented |
Instance Variable | policies |
Undocumented |
Instance Variable | tests |
Undocumented |
Instance Variable | trim |
Undocumented |
Instance Variable | undefined |
Undocumented |
Instance Variable | variable |
Undocumented |
Instance Variable | variable |
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 |
Undocumented |
Method | _generate |
Internal hook that can be overridden to hook a different generate method in. |
Method | _load |
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`. |