forked from orbit-oss/flask
Fixed a template loading bug
This commit is contained in:
parent
793a56bc8b
commit
1202996c63
1 changed files with 6 additions and 9 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue