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,
)
| 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( |
no test coverage detected