Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` and ``template_whitespace`` application settings. If a ``template_loader`` application setting
(self, template_path: str)
| 1037 | return namespace |
| 1038 | |
| 1039 | def create_template_loader(self, template_path: str) -> template.BaseLoader: |
| 1040 | """Returns a new template loader for the given path. |
| 1041 | |
| 1042 | May be overridden by subclasses. By default returns a |
| 1043 | directory-based loader on the given path, using the |
| 1044 | ``autoescape`` and ``template_whitespace`` application |
| 1045 | settings. If a ``template_loader`` application setting is |
| 1046 | supplied, uses that instead. |
| 1047 | """ |
| 1048 | settings = self.application.settings |
| 1049 | if "template_loader" in settings: |
| 1050 | return settings["template_loader"] |
| 1051 | kwargs = {} |
| 1052 | if "autoescape" in settings: |
| 1053 | # autoescape=None means "no escaping", so we have to be sure |
| 1054 | # to only pass this kwarg if the user asked for it. |
| 1055 | kwargs["autoescape"] = settings["autoescape"] |
| 1056 | if "template_whitespace" in settings: |
| 1057 | kwargs["whitespace"] = settings["template_whitespace"] |
| 1058 | return template.Loader(template_path, **kwargs) |
| 1059 | |
| 1060 | def flush(self, include_footers: bool = False) -> "Future[None]": |
| 1061 | """Flushes the current output buffer to the network. |