def get_template_source(name, dirs=None):
"""Retrieves the template's source contents.
:param name: Template's filename, as passed to the template loader.
:param dirs: list of directories to optionally override the defaults.
:return: tuple including file contents and file path.
"""
loaders = []
for loader in Engine.get_default().template_loaders:
# The cached loader includes the actual loaders underneath
if hasattr(loader, 'loaders'):
loaders.extend(loader.loaders)
else:
loaders.append(loader)
for loader in loaders:
try:
return loader.load_template_source(name, template_dirs=dirs)
except TemplateDoesNotExist:
pass
raise TemplateDoesNotExist(name)
评论列表
文章目录