the environment template loading functions now transparently
pass through a template object if it was passed to it. This
makes it possible to import or extend from a template object
that was passed to the template.
--HG--
branch : trunk
diff --git a/jinja2/environment.py b/jinja2/environment.py
index e3c64e3..4e9e4fd 100644
--- a/jinja2/environment.py
+++ b/jinja2/environment.py
@@ -552,6 +552,8 @@
If the template does not exist a :exc:`TemplateNotFound` exception is
raised.
"""
+ if isinstance(name, Template):
+ return name
if parent is not None:
name = self.join_path(name, parent)
return self._load_template(name, self.make_globals(globals))
@@ -569,6 +571,8 @@
u'of templates.')
globals = self.make_globals(globals)
for name in names:
+ if isinstance(name, Template):
+ return name
if parent is not None:
name = self.join_path(name, parent)
try:
@@ -588,6 +592,8 @@
"""
if isinstance(template_name_or_list, basestring):
return self.get_template(template_name_or_list, parent, globals)
+ elif isinstance(template_name_or_list, Template):
+ return template_name_or_list
return self.select_template(template_name_or_list, parent, globals)
def from_string(self, source, globals=None, template_class=None):