def get_source(self, environment, template_name):
final_path = template_name
if not template_name.startswith("/"):
for tdir in self.template_dirs:
full_path = os.path.join(tdir, template_name)
if os.path.isfile(full_path):
final_path = full_path
break
else:
full_path = os.path.join(tdir, template_name + self.template_extension)
if os.path.isfile(full_path):
final_path = full_path
break
else:
# See if parent can return it
if self.parent_loader:
return self.parent_loader.get_source(environment, template_name)
else:
source = pkgutil.get_data("onering", "data/templates/" + template_name).decode('utf-8')
return source, final_path, lambda: True
with file(final_path) as f:
source = f.read().decode('utf-8')
return source, final_path, lambda: mtime == getmtime(final_path)
评论列表
文章目录