Refs #25791 -- Added get_dirs() method to cached template loader.

This commit is contained in:
Tom Forbes 2020-05-17 15:10:09 +01:00 committed by Carlton Gibson
parent 859cd7c6b4
commit 29845ecf69
2 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,11 @@ class Loader(BaseLoader):
self.loaders = engine.get_template_loaders(loaders)
super().__init__(engine)
def get_dirs(self):
for loader in self.loaders:
if hasattr(loader, "get_dirs"):
yield from loader.get_dirs()
def get_contents(self, origin):
return origin.loader.get_contents(origin)

View File

@ -93,6 +93,10 @@ class CachedLoaderTests(SimpleTestCase):
"""
self.assertEqual(self.engine.template_loaders[0].cache_key(lazystr('template.html'), []), 'template.html')
def test_get_dirs(self):
inner_dirs = self.engine.template_loaders[0].loaders[0].get_dirs()
self.assertSequenceEqual(list(self.engine.template_loaders[0].get_dirs()), list(inner_dirs))
class FileSystemLoaderTests(SimpleTestCase):