OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """ | 2 """ |
3 jinja2.ext | 3 jinja2.ext |
4 ~~~~~~~~~~ | 4 ~~~~~~~~~~ |
5 | 5 |
6 Jinja extensions allow to add custom tags similar to the way django custom | 6 Jinja extensions allow to add custom tags similar to the way django custom |
7 tags work. By default two example extensions exist: an i18n and a cache | 7 tags work. By default two example extensions exist: an i18n and a cache |
8 extension. | 8 extension. |
9 | 9 |
10 :copyright: (c) 2010 by the Jinja Team. | 10 :copyright: (c) 2010 by the Jinja Team. |
11 :license: BSD. | 11 :license: BSD. |
12 """ | 12 """ |
13 from jinja2 import nodes | 13 from jinja2 import nodes |
14 from jinja2.defaults import BLOCK_START_STRING, \ | 14 from jinja2.defaults import BLOCK_START_STRING, \ |
15 BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \ | 15 BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \ |
16 COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \ | 16 COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \ |
17 LINE_COMMENT_PREFIX, TRIM_BLOCKS, NEWLINE_SEQUENCE, \ | 17 LINE_COMMENT_PREFIX, TRIM_BLOCKS, NEWLINE_SEQUENCE, \ |
18 KEEP_TRAILING_NEWLINE, LSTRIP_BLOCKS | 18 KEEP_TRAILING_NEWLINE, LSTRIP_BLOCKS |
19 from jinja2.environment import Environment | 19 from jinja2.environment import Environment |
20 from jinja2.runtime import concat | 20 from jinja2.runtime import concat |
21 from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError | 21 from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError |
22 from jinja2.utils import contextfunction, import_string, Markup | 22 from jinja2.utils import contextfunction, import_string, Markup |
23 from jinja2._compat import next, with_metaclass, string_types, iteritems | 23 from jinja2._compat import with_metaclass, string_types, iteritems |
24 | 24 |
25 | 25 |
26 # the only real useful gettext functions for a Jinja template. Note | 26 # the only real useful gettext functions for a Jinja template. Note |
27 # that ugettext must be assigned to gettext as Jinja doesn't support | 27 # that ugettext must be assigned to gettext as Jinja doesn't support |
28 # non unicode strings. | 28 # non unicode strings. |
29 GETTEXT_FUNCTIONS = ('_', 'gettext', 'ngettext') | 29 GETTEXT_FUNCTIONS = ('_', 'gettext', 'ngettext') |
30 | 30 |
31 | 31 |
32 class ExtensionRegistry(type): | 32 class ExtensionRegistry(type): |
33 """Gives the extension an unique identifier.""" | 33 """Gives the extension an unique identifier.""" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 for lineno, func, message in extract_from_ast(node, keywords): | 627 for lineno, func, message in extract_from_ast(node, keywords): |
628 yield lineno, func, message, finder.find_comments(lineno) | 628 yield lineno, func, message, finder.find_comments(lineno) |
629 | 629 |
630 | 630 |
631 #: nicer import names | 631 #: nicer import names |
632 i18n = InternationalizationExtension | 632 i18n = InternationalizationExtension |
633 do = ExprStmtExtension | 633 do = ExprStmtExtension |
634 loopcontrols = LoopControlExtension | 634 loopcontrols = LoopControlExtension |
635 with_ = WithExtension | 635 with_ = WithExtension |
636 autoescape = AutoEscapeExtension | 636 autoescape = AutoEscapeExtension |
OLD | NEW |