(
self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]]
)
| 955 | |
| 956 | @internalcode |
| 957 | def _load_template( |
| 958 | self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]] |
| 959 | ) -> "Template": |
| 960 | if self.loader is None: |
| 961 | raise TypeError("no loader for this environment specified") |
| 962 | cache_key = (weakref.ref(self.loader), name) |
| 963 | if self.cache is not None: |
| 964 | template = self.cache.get(cache_key) |
| 965 | if template is not None and ( |
| 966 | not self.auto_reload or template.is_up_to_date |
| 967 | ): |
| 968 | # template.globals is a ChainMap, modifying it will only |
| 969 | # affect the template, not the environment globals. |
| 970 | if globals: |
| 971 | template.globals.update(globals) |
| 972 | |
| 973 | return template |
| 974 | |
| 975 | template = self.loader.load(self, name, self.make_globals(globals)) |
| 976 | |
| 977 | if self.cache is not None: |
| 978 | self.cache[cache_key] = template |
| 979 | return template |
| 980 | |
| 981 | @internalcode |
| 982 | def get_template( |
no test coverage detected