diff --git a/src/capport/api/app_cls.py b/src/capport/api/app_cls.py index eb5f2c2..76caecc 100644 --- a/src/capport/api/app_cls.py +++ b/src/capport/api/app_cls.py @@ -21,11 +21,24 @@ class DispatchingJinjaLoader(quart.templating.DispatchingJinjaLoader): def __init__(self, app: MyQuartApp) -> None: super().__init__(app) - def _loaders(self) -> typing.Generator[jinja2.BaseLoader, None, None]: + def get_source( + self, + environment: typing.Any, + template: str, + ) -> tuple[str, str | None, typing.Callable | None]: if self.app.custom_loader: - yield self.app.custom_loader - for loader in super()._loaders(): - yield loader + try: + return self.app.custom_loader.get_source(environment, template) + except jinja2.TemplateNotFound: + pass + return super().get_source(environment, template) + + def list_templates(self) -> list[str]: + result = set() + if self.app.custom_loader: + result.update(self.app.custom_loader.list_templates()) + result.update(super().list_templates()) + return list(result) class MyQuartApp(quart_trio.QuartTrio):