__init__.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # -*- coding: utf-8 -*-
  2. """
  3. jinja2
  4. ~~~~~~
  5. Jinja2 is a template engine written in pure Python. It provides a
  6. Django inspired non-XML syntax but supports inline expressions and
  7. an optional sandboxed environment.
  8. Nutshell
  9. --------
  10. Here a small example of a Jinja2 template::
  11. {% extends 'base.html' %}
  12. {% block title %}Memberlist{% endblock %}
  13. {% block content %}
  14. <ul>
  15. {% for user in users %}
  16. <li><a href="{{ user.url }}">{{ user.username }}</a></li>
  17. {% endfor %}
  18. </ul>
  19. {% endblock %}
  20. :copyright: (c) 2017 by the Jinja Team.
  21. :license: BSD, see LICENSE for more details.
  22. """
  23. __docformat__ = 'restructuredtext en'
  24. __version__ = '2.10'
  25. # high level interface
  26. from jinja2.environment import Environment, Template
  27. # loaders
  28. from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
  29. DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
  30. ModuleLoader
  31. # bytecode caches
  32. from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
  33. MemcachedBytecodeCache
  34. # undefined types
  35. from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined, \
  36. make_logging_undefined
  37. # exceptions
  38. from jinja2.exceptions import TemplateError, UndefinedError, \
  39. TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
  40. TemplateAssertionError, TemplateRuntimeError
  41. # decorators and public utilities
  42. from jinja2.filters import environmentfilter, contextfilter, \
  43. evalcontextfilter
  44. from jinja2.utils import Markup, escape, clear_caches, \
  45. environmentfunction, evalcontextfunction, contextfunction, \
  46. is_undefined, select_autoescape
  47. __all__ = [
  48. 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
  49. 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
  50. 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
  51. 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
  52. 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
  53. 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
  54. 'TemplateRuntimeError',
  55. 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
  56. 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
  57. 'evalcontextfilter', 'evalcontextfunction', 'make_logging_undefined',
  58. 'select_autoescape',
  59. ]
  60. def _patch_async():
  61. from jinja2.utils import have_async_gen
  62. if have_async_gen:
  63. from jinja2.asyncsupport import patch_all
  64. patch_all()
  65. _patch_async()
  66. del _patch_async