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

Method new_context

src/jinja2/environment.py:1375–1390  ·  src/jinja2/environment.py::Template.new_context

Create a new :class:`Context` for this template. The vars provided will be passed to the template. Per default the globals are added to the context. If shared is set to `True` the data is passed as is to the context without adding the globals. `locals` can be a di

(
        self,
        vars: t.Optional[t.Dict[str, t.Any]] = None,
        shared: bool = False,
        locals: t.Optional[t.Mapping[str, t.Any]] = None,
    )

Source from the content-addressed store, hash-verified

1373 yield self.environment.handle_exception()
1374
1375 def new_context(
1376 self,
1377 vars: t.Optional[t.Dict[str, t.Any]] = None,
1378 shared: bool = False,
1379 locals: t.Optional[t.Mapping[str, t.Any]] = None,
1380 ) -> Context:
1381 class="st">"""Create a new :class:`Context` for this template. The vars
1382 provided will be passed to the template. Per default the globals
1383 are added to the context. If shared is set to `True` the data
1384 is passed as is to the context without adding the globals.
1385
1386 `locals` can be a dict of local variables for internal usage.
1387 class="st">"""
1388 return new_context(
1389 self.environment, self.name, self.blocks, vars, shared, self.globals, locals
1390 )
1391
1392 def make_module(
1393 self,

Callers 9

renderMethod · 0.95
render_asyncMethod · 0.95
generateMethod · 0.95
generate_asyncMethod · 0.95
make_moduleMethod · 0.95
make_module_asyncMethod · 0.95
__call__Method · 0.80
renderMethod · 0.80
render_asyncMethod · 0.80

Calls 1

new_contextFunction · 0.85

Tested by

no test coverage detected