defaults.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. """
  3. jinja2.defaults
  4. ~~~~~~~~~~~~~~~
  5. Jinja default filters and tags.
  6. :copyright: (c) 2017 by the Jinja Team.
  7. :license: BSD, see LICENSE for more details.
  8. """
  9. from jinja2._compat import range_type
  10. from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner, Namespace
  11. # defaults for the parser / lexer
  12. BLOCK_START_STRING = '{%'
  13. BLOCK_END_STRING = '%}'
  14. VARIABLE_START_STRING = '{{'
  15. VARIABLE_END_STRING = '}}'
  16. COMMENT_START_STRING = '{#'
  17. COMMENT_END_STRING = '#}'
  18. LINE_STATEMENT_PREFIX = None
  19. LINE_COMMENT_PREFIX = None
  20. TRIM_BLOCKS = False
  21. LSTRIP_BLOCKS = False
  22. NEWLINE_SEQUENCE = '\n'
  23. KEEP_TRAILING_NEWLINE = False
  24. # default filters, tests and namespace
  25. from jinja2.filters import FILTERS as DEFAULT_FILTERS
  26. from jinja2.tests import TESTS as DEFAULT_TESTS
  27. DEFAULT_NAMESPACE = {
  28. 'range': range_type,
  29. 'dict': dict,
  30. 'lipsum': generate_lorem_ipsum,
  31. 'cycler': Cycler,
  32. 'joiner': Joiner,
  33. 'namespace': Namespace
  34. }
  35. # default policies
  36. DEFAULT_POLICIES = {
  37. 'compiler.ascii_str': True,
  38. 'urlize.rel': 'noopener',
  39. 'urlize.target': None,
  40. 'truncate.leeway': 5,
  41. 'json.dumps_function': None,
  42. 'json.dumps_kwargs': {'sort_keys': True},
  43. 'ext.i18n.trimmed': False,
  44. }
  45. # export all constants
  46. __all__ = tuple(x for x in locals().keys() if x.isupper())