MCPcopy
hub / github.com/pallets/jinja / _load_template

Method _load_template

src/jinja2/environment.py:957–979  ·  view source on GitHub ↗
(
        self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]]
    )

Source from the content-addressed store, hash-verified

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(

Callers 2

get_templateMethod · 0.95
select_templateMethod · 0.95

Calls 4

make_globalsMethod · 0.95
refMethod · 0.80
getMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected