Extension API for adding custom tags and behavior.
Class |
|
A ``{% debug %}`` tag that dumps the available variables, filters, and tests. |
Class |
|
Adds a `do` tag to Jinja that works like the print statement just that it doesn't print the return value. |
Class |
|
Extensions can be used to add extra functionality to the Jinja template system at the parser level. Custom extensions are bound to an environment but may not store environment specific data on `self`. ... |
Class |
|
This extension adds gettext support to Jinja. |
Class |
|
Adds break and continue to the template engine. |
Function | babel |
Babel extraction method for Jinja templates. |
Function | extract |
Extract localizable strings from the given template node. Per default this function returns matches in babel style that means non string parameters as well as keyword arguments are returned as `None`. ... |
Constant | GETTEXT |
Undocumented |
Class | _ |
Helper class to find comments in a token stream. Can only find comments for gettext calls forwards. Once the comment from line 4 is found, a comment for line 1 will not return a usable value. |
Class | _ |
Undocumented |
Class | _ |
Undocumented |
Function | _gettext |
Undocumented |
Function | _make |
Undocumented |
Function | _make |
Undocumented |
Function | _make |
Undocumented |
Function | _make |
Undocumented |
Variable | _ |
Undocumented |
Variable | _ws |
Undocumented |
Babel extraction method for Jinja templates. .. versionchanged:: 2.3 Basic support for translation comments was added. If `comment_tags` is now set to a list of keywords for extraction, the extractor will try to find the best preceding comment that begins with one of the keywords. For best results, make sure to not have more than one gettext call in one line of code and the matching comment in the same line or the line before. .. versionchanged:: 2.5.1 The `newstyle_gettext` flag can be set to `True` to enable newstyle gettext calls. .. versionchanged:: 2.7 A `silent` option can now be provided. If set to `False` template syntax errors are propagated instead of being ignored. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator tags to search for and include in the results. :param options: a dictionary of additional options (optional) :return: an iterator over ``(lineno, funcname, message, comments)`` tuples. (comments will be empty currently)
Parameters | |
fileobj:t.BinaryIO | Undocumented |
keywords:t.Sequence[ | Undocumented |
commentt.Sequence[ | Undocumented |
options:t.Dict[ | Undocumented |
Returns | |
t.Iterator[ | Undocumented |
Extract localizable strings from the given template node. Per default this function returns matches in babel style that means non string parameters as well as keyword arguments are returned as `None`. This allows Babel to figure out what you really meant if you are using gettext functions that allow keyword arguments for placeholder expansion. If you don't want that behavior set the `babel_style` parameter to `False` which causes only strings to be returned and parameters are always stored in tuples. As a consequence invalid gettext calls (calls without a single string parameter or string parameters after non-string parameters) are skipped. This example explains the behavior: >>> from jinja2 import Environment >>> env = Environment() >>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}') >>> list(extract_from_ast(node)) [(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))] >>> list(extract_from_ast(node, babel_style=False)) [(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))] For every string found this function yields a ``(lineno, function, message)`` tuple, where: * ``lineno`` is the number of the line on which the string was found, * ``function`` is the name of the ``gettext`` function used (if the string was extracted from embedded Python code), and * ``message`` is the string, or a tuple of strings for functions with multiple string arguments. This extraction function operates on the AST and is because of that unable to extract any comments. For comment support you have to use the babel extraction interface or extract comments yourself.
Parameters | |
ast:nodes.Template | Undocumented |
gettextt.Sequence[ | Undocumented |
babelbool | Undocumented |
Returns | |
t.Iterator[ | Undocumented |
Undocumented
Parameters | |
func:t.Callable[ | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Undocumented
Parameters | |
func:t.Callable[ | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Undocumented
Parameters | |
func:t.Callable[ | Undocumented |
Returns | |
t.Callable[ | Undocumented |
Undocumented
Parameters | |
func:t.Callable[ | Undocumented |
Returns | |
t.Callable[ | Undocumented |