From: David Lord Date: Thu, 6 Jul 2017 17:43:21 +0000 (-0700) Subject: fix docs warnings X-Git-Tag: 2.10~18^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ffbf8e5715bb4512b14427ba237b61f484a39c4;p=thirdparty%2Fjinja.git fix docs warnings --- diff --git a/docs/extensions.rst b/docs/extensions.rst index 00adee9f..3663060b 100644 --- a/docs/extensions.rst +++ b/docs/extensions.rst @@ -27,8 +27,8 @@ i18n Extension **Import name:** `jinja2.ext.i18n` -The i18n extension can be used in combination with `gettext`_ or `babel`_. If -the i18n extension is enabled Jinja2 provides a `trans` statement that marks +The i18n extension can be used in combination with `gettext`_ or `babel`_. If +the i18n extension is enabled Jinja2 provides a `trans` statement that marks the wrapped string as translatable and calls `gettext`. After enabling, dummy `_` function that forwards calls to `gettext` is added @@ -303,7 +303,7 @@ extensions: The current :class:`~jinja2.lexer.TokenStream` .. autoclass:: jinja2.lexer.TokenStream - :members: push, look, eos, skip, next, next_if, skip_if, expect + :members: push, look, eos, skip, __next__, next_if, skip_if, expect .. attribute:: current diff --git a/docs/templates.rst b/docs/templates.rst index 62852c4b..fd3408a7 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -197,14 +197,14 @@ without the `trim_blocks` and `lstrip_blocks` options, this template:: gets rendered with blank lines inside the div::
- + yay - +
But with both `trim_blocks` and `lstrip_blocks` enabled, the template block lines are removed and other whitespace is preserved:: - +
yay
@@ -522,12 +522,12 @@ Working with Automatic Escaping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When automatic escaping is enabled, everything is escaped by default except -for values explicitly marked as safe. Variables and expressions +for values explicitly marked as safe. Variables and expressions can be marked as safe either in: a. the context dictionary by the application with `MarkupSafe.Markup`, or b. the template, with the `|safe` filter - + The main problem with this approach is that Python itself doesn't have the concept of tainted values; so whether a value is safe or unsafe can get lost. @@ -1300,6 +1300,8 @@ something else>``. The `else` part is optional. If not provided, the else block implicitly evaluates into an undefined object:: +.. sourcecode:: jinja + {{ '[%s]' % page.title if page.title }} diff --git a/jinja2/lexer.py b/jinja2/lexer.py index 679e3f25..6fd135dd 100644 --- a/jinja2/lexer.py +++ b/jinja2/lexer.py @@ -347,7 +347,10 @@ class TokenStream(object): return self.next_if(expr) is not None def __next__(self): - """Go one token ahead and return the old one""" + """Go one token ahead and return the old one. + + Use the built-in :func:`next` instead of calling this directly. + """ rv = self.current if self._pushed: self.current = self._pushed.popleft()