MCPcopy Create free account
hub / github.com/nodejs/node / load

Method load

deps/v8/third_party/jinja2/loaders.py:636–661  ·  view source on GitHub ↗
(
        self,
        environment: "Environment",
        name: str,
        globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
    )

Source from the content-addressed store, hash-verified

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 )

Callers

nothing calls this directly

Calls 4

get_template_keyMethod · 0.95
popMethod · 0.80
TemplateNotFoundClass · 0.70
from_module_dictMethod · 0.45

Tested by

no test coverage detected