From 1202996c634b23f82421753cb7c46a5ccdf7aca2 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 15 Jul 2010 18:10:26 +0200 Subject: [PATCH] Fixed a template loading bug --- flask/templating.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/flask/templating.py b/flask/templating.py index c55d4826..a6fd0982 100644 --- a/flask/templating.py +++ b/flask/templating.py @@ -35,23 +35,20 @@ class _DispatchingJinjaLoader(BaseLoader): self.app = app def get_source(self, environment, template): + loader = None try: module, name = template.split('/', 1) loader = self.app.modules[module].jinja_loader - if loader is None: - raise ValueError() except (ValueError, KeyError): - loader = self.app.jinja_loader - if loader is not None: - return loader.get_source(environment, template) - else: + pass + # if there was a module and it has a loader, try this first + if loader is not None: try: return loader.get_source(environment, name) except TemplateNotFound: pass - # raise the exception with the correct filename here. - # (the one that includes the prefix) - raise TemplateNotFound(template) + # fall back to application loader if module failed + return self.app.jinja_loader.get_source(environment, template) def list_templates(self): result = self.app.jinja_loader.list_templates()