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

Method __new__

src/jinja2/environment.py:1167–1214  ·  view source on GitHub ↗
(
        cls,
        source: t.Union[str, nodes.Template],
        block_start_string: str = BLOCK_START_STRING,
        block_end_string: str = BLOCK_END_STRING,
        variable_start_string: str = VARIABLE_START_STRING,
        variable_end_string: str = VARIABLE_END_STRING,
        comment_start_string: str = COMMENT_START_STRING,
        comment_end_string: str = COMMENT_END_STRING,
        line_statement_prefix: t.Optional[str] = LINE_STATEMENT_PREFIX,
        line_comment_prefix: t.Optional[str] = LINE_COMMENT_PREFIX,
        trim_blocks: bool = TRIM_BLOCKS,
        lstrip_blocks: bool = LSTRIP_BLOCKS,
        newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = NEWLINE_SEQUENCE,
        keep_trailing_newline: bool = KEEP_TRAILING_NEWLINE,
        extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = (),
        optimized: bool = True,
        undefined: t.Type[Undefined] = Undefined,
        finalize: t.Optional[t.Callable[..., t.Any]] = None,
        autoescape: t.Union[bool, t.Callable[[t.Optional[str]], bool]] = False,
        enable_async: bool = False,
    )

Source from the content-addressed store, hash-verified

1165 _uptodate: t.Optional[t.Callable[[], bool]]
1166
1167 def __new__(
1168 cls,
1169 source: t.Union[str, nodes.Template],
1170 block_start_string: str = BLOCK_START_STRING,
1171 block_end_string: str = BLOCK_END_STRING,
1172 variable_start_string: str = VARIABLE_START_STRING,
1173 variable_end_string: str = VARIABLE_END_STRING,
1174 comment_start_string: str = COMMENT_START_STRING,
1175 comment_end_string: str = COMMENT_END_STRING,
1176 line_statement_prefix: t.Optional[str] = LINE_STATEMENT_PREFIX,
1177 line_comment_prefix: t.Optional[str] = LINE_COMMENT_PREFIX,
1178 trim_blocks: bool = TRIM_BLOCKS,
1179 lstrip_blocks: bool = LSTRIP_BLOCKS,
1180 newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = NEWLINE_SEQUENCE,
1181 keep_trailing_newline: bool = KEEP_TRAILING_NEWLINE,
1182 extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = (),
1183 optimized: bool = True,
1184 undefined: t.Type[Undefined] = Undefined,
1185 finalize: t.Optional[t.Callable[..., t.Any]] = None,
1186 autoescape: t.Union[bool, t.Callable[[t.Optional[str]], bool]] = False,
1187 enable_async: bool = False,
1188 ) -> t.Any: # it returns a `Template`, but this breaks the sphinx build...
1189 env = get_spontaneous_environment(
1190 cls.environment_class, # type: ignore
1191 block_start_string,
1192 block_end_string,
1193 variable_start_string,
1194 variable_end_string,
1195 comment_start_string,
1196 comment_end_string,
1197 line_statement_prefix,
1198 line_comment_prefix,
1199 trim_blocks,
1200 lstrip_blocks,
1201 newline_sequence,
1202 keep_trailing_newline,
1203 frozenset(extensions),
1204 optimized,
1205 undefined, # type: ignore
1206 finalize,
1207 autoescape,
1208 None,
1209 0,
1210 False,
1211 None,
1212 enable_async,
1213 )
1214 return env.from_string(source, template_class=cls)
1215
1216 @classmethod
1217 def from_code(

Callers 2

overlayMethod · 0.45
_from_namespaceMethod · 0.45

Calls 2

from_stringMethod · 0.80

Tested by

no test coverage detected