Skip to content
Myr

moved environment defaults to jinja2.defaults

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent f3c35c4 · Browse files · 3 files+34 added−33 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+34 added−33 removed

  • other:+34 added−33 removed

3 files+34 added−33 removed

modified:jinja2/defaults.py+6 added-2 removed
6 unmodified lines
78 :copyright: 2007-2008 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11from jinja2.filters import FILTERS as DEFAULT_FILTERS12from jinja2.tests import TESTS as DEFAULT_TESTS11from jinja2.utils import generate_lorem_ipsum121314# defaults for the parser / lexer15BLOCK_START_STRING = '{%'16BLOCK_END_STRING = '%}'17VARIABLE_START_STRING = '{{'18VARIABLE_END_STRING = '}}'19COMMENT_START_STRING = '{#'20COMMENT_END_STRING = '#}'21LINE_STATEMENT_PREFIX = None22TRIM_BLOCKS = False23NEWLINE_SEQUENCE = '\n'242526# default filters, tests and namespace27from jinja2.filters import FILTERS as DEFAULT_FILTERS28from jinja2.tests import TESTS as DEFAULT_TESTS29DEFAULT_NAMESPACE = {30 'range': xrange,31 'dict': lambda **kw: kw,32 'lipsum': generate_lorem_ipsum
5 unmodified lines
modified:jinja2/environment.py+11 added-11 removed
176 unmodified lines
177 variable_end_string=VARIABLE_END_STRING,178 comment_start_string=COMMENT_START_STRING,179 comment_end_string=COMMENT_END_STRING,180 line_statement_prefix=LINE_STATEMENT_PREFIX,181 trim_blocks=False,182 newline_sequence='\n',181 trim_blocks=TRIM_BLOCKS,182 newline_sequence=NEWLINE_SEQUENCE,183 extensions=(),184 optimized=True,185 undefined=Undefined,186 finalize=None,
254 unmodified lines
441 StopIteration442 """443444 def __new__(cls, source,445 block_start_string='{%',446 block_end_string='%}',447 variable_start_string='{{',448 variable_end_string='}}',449 comment_start_string='{#',450 comment_end_string='#}',451 line_statement_prefix=None,452 trim_blocks=False,453 newline_sequence='\n',445 block_start_string=BLOCK_START_STRING,446 block_end_string=BLOCK_END_STRING,447 variable_start_string=VARIABLE_START_STRING,448 variable_end_string=VARIABLE_END_STRING,449 comment_start_string=COMMENT_START_STRING,450 comment_end_string=COMMENT_END_STRING,451 line_statement_prefix=LINE_STATEMENT_PREFIX,452 trim_blocks=TRIM_BLOCKS,453 newline_sequence=NEWLINE_SEQUENCE,454 extensions=(),455 optimized=True,456 undefined=Undefined,457 finalize=None,
233 unmodified lines
modified:jinja2/ext.py+17 added-20 removed
10 unmodified lines
11 :license: BSD.12"""13from collections import deque14from jinja2 import nodes15from jinja2.defaults import *16from jinja2.environment import get_spontaneous_environment17from jinja2.runtime import Undefined, concat18from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError19from jinja2.utils import contextfunction, import_string, Markup
323 unmodified lines
343 :param options: a dictionary of additional options (optional)344 :return: an iterator over ``(lineno, funcname, message, comments)`` tuples.345 (comments will be empty currently)346 """346 encoding = options.get('encoding', 'utf-8')347348 have_trans_extension = False349 extensions = []347 extensions = set()348 for extension in options.get('extensions', '').split(','):349 extension = extension.strip()350 if not extension:351 continue354 extension = import_string(extension)355 if extension is InternationalizationExtension:356 have_trans_extension = True357 extensions.append(extension)358 if not have_trans_extension:359 extensions.append(InternationalizationExtension)352 extensions.add(import_string(extension))353 if InternationalizationExtension not in extensions:354 extensions.add(InternationalizationExtension)355356 environment = get_spontaneous_environment(362 options.get('block_start_string', '{%'),363 options.get('block_end_string', '%}'),364 options.get('variable_start_string', '{{'),365 options.get('variable_end_string', '}}'),366 options.get('comment_start_string', '{#'),367 options.get('comment_end_string', '#}'),368 options.get('line_statement_prefix') or None,369 options.get('trim_blocks', '').lower() in ('1', 'on', 'yes', 'true'),370 '\n', frozenset(extensions),357 options.get('block_start_string', BLOCK_START_STRING),358 options.get('block_end_string', BLOCK_END_STRING),359 options.get('variable_start_string', VARIABLE_START_STRING),360 options.get('variable_end_string', VARIABLE_END_STRING),361 options.get('comment_start_string', COMMENT_START_STRING),362 options.get('comment_end_string', COMMENT_END_STRING),363 options.get('line_statement_prefix') or LINE_STATEMENT_PREFIX,364 str(options.get('trim_blocks', TRIM_BLOCKS)).lower() in \365 ('1', 'on', 'yes', 'true'),366 NEWLINE_SEQUENCE, frozenset(extensions),367 # fill with defaults so that environments are shared368 # with other spontaneus environments. The rest of the369 # arguments are optimizer, undefined, finalize, autoescape,370 # loader, cache size and auto reloading setting371 True, Undefined, None, False, None, 0, False372 )373378 node = environment.parse(fileobj.read().decode(encoding))374 source = fileobj.read().decode(options.get('encoding', 'utf-8'))375 node = environment.parse(source)376 for lineno, func, message in extract_from_ast(node, keywords):377 yield lineno, func, message, []378379
4 unmodified lines