(
self,
environment: "Environment",
name: str,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
)
| 634 | |
| 635 | @internalcode |
| 636 | def load( |
| 637 | self, |
| 638 | environment: "Environment", |
| 639 | name: str, |
| 640 | globals: t.Optional[t.MutableMapping[str, t.Any]] = None, |
| 641 | ) -> "Template": |
| 642 | key = self.get_template_key(name) |
| 643 | module = f"{self.package_name}.{key}" |
| 644 | mod = getattr(self.module, module, None) |
| 645 | |
| 646 | if mod is None: |
| 647 | try: |
| 648 | mod = __import__(module, None, None, ["root"]) |
| 649 | except ImportError as e: |
| 650 | raise TemplateNotFound(name) from e |
| 651 | |
| 652 | # remove the entry from sys.modules, we only want the attribute |
| 653 | # on the module object we have stored on the loader. |
| 654 | sys.modules.pop(module, None) |
| 655 | |
| 656 | if globals is None: |
| 657 | globals = {} |
| 658 | |
| 659 | return environment.template_class.from_module_dict( |
| 660 | environment, mod.__dict__, globals |
| 661 | ) |
nothing calls this directly
no test coverage detected