Holds evaluation time information. Custom attributes can be attached to it in extensions.
| 69 | |
| 70 | |
| 71 | class EvalContext: |
| 72 | """Holds evaluation time information. Custom attributes can be attached |
| 73 | to it in extensions. |
| 74 | """ |
| 75 | |
| 76 | def __init__( |
| 77 | self, environment: "Environment", template_name: t.Optional[str] = None |
| 78 | ) -> None: |
| 79 | self.environment = environment |
| 80 | if callable(environment.autoescape): |
| 81 | self.autoescape = environment.autoescape(template_name) |
| 82 | else: |
| 83 | self.autoescape = environment.autoescape |
| 84 | self.volatile = False |
| 85 | |
| 86 | def save(self) -> t.Mapping[str, t.Any]: |
| 87 | return self.__dict__.copy() |
| 88 | |
| 89 | def revert(self, old: t.Mapping[str, t.Any]) -> None: |
| 90 | self.__dict__.clear() |
| 91 | self.__dict__.update(old) |
| 92 | |
| 93 | |
| 94 | def get_eval_context(node: "Node", ctx: t.Optional[EvalContext]) -> EvalContext: |
no outgoing calls