MCPcopy Create free account
hub / github.com/nodejs/node / make_globals

Method make_globals

deps/v8/third_party/jinja2/environment.py:1113–1133  ·  view source on GitHub ↗

Make the globals map for a template. Any given template globals overlay the environment :attr:`globals`. Returns a :class:`collections.ChainMap`. This allows any changes to a template's globals to only affect that template, while changes to the environment's globals

(
        self, d: t.Optional[t.MutableMapping[str, t.Any]]
    )

Source from the content-addressed store, hash-verified

1111 return cls.from_code(self, self.compile(source), gs, None)
1112
1113 def make_globals(
1114 self, d: t.Optional[t.MutableMapping[str, t.Any]]
1115 ) -> t.MutableMapping[str, t.Any]:
1116 """Make the globals map for a template. Any given template
1117 globals overlay the environment :attr:`globals`.
1118
1119 Returns a :class:`collections.ChainMap`. This allows any changes
1120 to a template's globals to only affect that template, while
1121 changes to the environment's globals are still reflected.
1122 However, avoid modifying any globals after a template is loaded.
1123
1124 :param d: Dict of template-specific globals.
1125
1126 .. versionchanged:: 3.0
1127 Use :class:`collections.ChainMap` to always prevent mutating
1128 environment globals.
1129 """
1130 if d is None:
1131 d = {}
1132
1133 return ChainMap(d, self.globals)
1134
1135
1136class Template:

Callers 2

_load_templateMethod · 0.95
from_stringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected