compilation you can set ignore_errors to False and you will get an exception
on syntax errors.
If py_compile is set to True .pyc files will be written to the target instead of
standard .py files. This flag does not do anything on pypy and Python 3
where pyc files are not picked up by itself and don’t give much benefit.
New in version 2.4.
extend(**attributes)
Add the items to the instance of the environment if they do not exist yet.
This is used by extensions to register callbacks and configuration values
without breaking inheritance.
from_string(source, globals=None, template_class=None)
Load a template from a string. This parses the source given and returns a
Template object.
get_or_select_template(template_name_or_list, parent=None, globals=None)
Does a typecheck and dispatches to select_template() if an iterable of tem-
plate names is given, otherwise to get_template().
New in version 2.3.
get_template(name, parent=None, globals=None)
Load a template from the loader. If a loader is configured this method ask
the loader for the template and returns a Template. If the parent parameter is
not None, join_path() is called to get the real template name before loading.
The globals parameter can be used to provide template wide globals. These
variables are available in the context at render time.
If the template does not exist a TemplateNotFound exception is raised.
Changed in version 2.4: If name is a Template object it is returned from the
function unchanged.
join_path(template, parent)
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.
Subclasses may override this method and implement template path joining
here.
list_templates(extensions=None, filter_func=None)
Returns a list of templates for this environment. This requires that the
loader supports the loader’s list_templates() method.
If there are other files in the template folder besides the actual templates, the
returned list can be filtered. There are two ways: either extensions is set to a
list of file extensions for templates, or a filter_func can be provided which is
a callable that is passed a template name and should return True if it should
end up in the result list.
13