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

Class EvalContext

src/jinja2/nodes.py:71–91  ·  view source on GitHub ↗

Holds evaluation time information. Custom attributes can be attached to it in extensions.

Source from the content-addressed store, hash-verified

69
70
71class 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
94def get_eval_context(node: "Node", ctx: t.Optional[EvalContext]) -> EvalContext:

Callers 5

test_template_dataMethod · 0.90
__init__Method · 0.85
_filter_test_commonMethod · 0.85
visit_TemplateMethod · 0.85
get_eval_contextFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_template_dataMethod · 0.72