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

Method from_code

src/jinja2/environment.py:1217–1231  ·  view source on GitHub ↗

Creates a template object from compiled code and the globals. This is used by the loaders and environment to create a template object.

(
        cls,
        environment: Environment,
        code: CodeType,
        globals: t.MutableMapping[str, t.Any],
        uptodate: t.Optional[t.Callable[[], bool]] = None,
    )

Source from the content-addressed store, hash-verified

1215
1216 @classmethod
1217 def from_code(
1218 cls,
1219 environment: Environment,
1220 code: CodeType,
1221 globals: t.MutableMapping[str, t.Any],
1222 uptodate: t.Optional[t.Callable[[], bool]] = None,
1223 ) -> "Template":
1224 """Creates a template object from compiled code and the globals. This
1225 is used by the loaders and environment to create a template object.
1226 """
1227 namespace = {"environment": environment, "__file__": code.co_filename}
1228 exec(code, namespace)
1229 rv = cls._from_namespace(environment, namespace, globals)
1230 rv._uptodate = uptodate
1231 return rv
1232
1233 @classmethod
1234 def from_module_dict(

Callers 2

loadMethod · 0.80
from_stringMethod · 0.80

Calls 1

_from_namespaceMethod · 0.80

Tested by

no test coverage detected