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

Class Environment

src/jinja2/environment.py:144–1133  ·  view source on GitHub ↗

r"""The core component of Jinja is the `Environment`. It contains important shared variables like configuration, filters, tests, globals and others. Instances of this class may be modified if they are not shared and if no template was loaded so far. Modifications on environments af

Source from the content-addressed store, hash-verified

142
143
144class Environment:
145 r"""The core component of Jinja is the `Environment`. It contains
146 important shared variables like configuration, filters, tests,
147 globals and others. Instances of this class may be modified if
148 they are not shared and if no template was loaded so far.
149 Modifications on environments after the first template was loaded
150 will lead to surprising effects and undefined behavior.
151
152 Here are the possible initialization parameters:
153
154 `block_start_string`
155 The string marking the beginning of a block. Defaults to ``'{%'``.
156
157 `block_end_string`
158 The string marking the end of a block. Defaults to ``'%}'``.
159
160 `variable_start_string`
161 The string marking the beginning of a print statement.
162 Defaults to ``'{{'``.
163
164 `variable_end_string`
165 The string marking the end of a print statement. Defaults to
166 ``'}}'``.
167
168 `comment_start_string`
169 The string marking the beginning of a comment. Defaults to ``'{#'``.
170
171 `comment_end_string`
172 The string marking the end of a comment. Defaults to ``'#}'``.
173
174 `line_statement_prefix`
175 If given and a string, this will be used as prefix for line based
176 statements. See also :ref:`line-statements`.
177
178 `line_comment_prefix`
179 If given and a string, this will be used as prefix for line based
180 comments. See also :ref:`line-statements`.
181
182 .. versionadded:: 2.2
183
184 `trim_blocks`
185 If this is set to ``True`` the first newline after a block is
186 removed (block, not variable tag!). Defaults to `False`.
187
188 `lstrip_blocks`
189 If this is set to ``True`` leading spaces and tabs are stripped
190 from the start of a line to a block. Defaults to `False`.
191
192 `newline_sequence`
193 The sequence that starts a newline. Must be one of ``'\r'``,
194 ``'\n'`` or ``'\r\n'``. The default is ``'\n'`` which is a
195 useful default for Linux and OS X systems as well as web
196 applications.
197
198 `keep_trailing_newline`
199 Preserve the trailing newline when rendering templates.
200 The default is ``False``, which causes a single newline,
201 if present, to be stripped from the end of the template.

Callers 15

envFunction · 0.90
test_superMethod · 0.90
test_preserve_blocksMethod · 0.90
test_scoped_blockMethod · 0.90
test_level1_requiredMethod · 0.90
test_level2_requiredMethod · 0.90
test_level3_requiredMethod · 0.90
test_invalid_requiredMethod · 0.90

Calls

no outgoing calls

Tested by 15

envFunction · 0.72
test_superMethod · 0.72
test_preserve_blocksMethod · 0.72
test_scoped_blockMethod · 0.72
test_level1_requiredMethod · 0.72
test_level2_requiredMethod · 0.72
test_level3_requiredMethod · 0.72
test_invalid_requiredMethod · 0.72