Browse Source

Fixed a template loading bug

pull/112/head
Armin Ronacher 15 years ago
parent
commit
1202996c63
  1. 15
      flask/templating.py

15
flask/templating.py

@ -35,23 +35,20 @@ class _DispatchingJinjaLoader(BaseLoader):
self.app = app self.app = app
def get_source(self, environment, template): def get_source(self, environment, template):
loader = None
try: try:
module, name = template.split('/', 1) module, name = template.split('/', 1)
loader = self.app.modules[module].jinja_loader loader = self.app.modules[module].jinja_loader
if loader is None:
raise ValueError()
except (ValueError, KeyError): except (ValueError, KeyError):
loader = self.app.jinja_loader pass
if loader is not None: # if there was a module and it has a loader, try this first
return loader.get_source(environment, template) if loader is not None:
else:
try: try:
return loader.get_source(environment, name) return loader.get_source(environment, name)
except TemplateNotFound: except TemplateNotFound:
pass pass
# raise the exception with the correct filename here. # fall back to application loader if module failed
# (the one that includes the prefix) return self.app.jinja_loader.get_source(environment, template)
raise TemplateNotFound(template)
def list_templates(self): def list_templates(self):
result = self.app.jinja_loader.list_templates() result = self.app.jinja_loader.list_templates()

Loading…
Cancel
Save