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