Skip to content
Myr

document formatting methods in format filter

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #566

authored by David Lord · committed by David Lord · parent 36ba250 · Browse files · 1 file+15 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−4 removed

  • other:+15 added−4 removed

1 file+15 added−4 removed

modified:jinja2/filters.py+15 added-4 removed
741 unmodified lines
742 return default743744745def do_format(value, *args, **kwargs):746 """747 Apply python string formatting on an object:746 """Apply the given values to a `printf-style`_ format string, like747 ``string % values``.748749 .. sourcecode:: jinja750751 {{ "%s - %s"|format("Hello?", "Foo!") }}752 -> Hello? - Foo!751 {{ "%s, %s!"|format(greeting, name) }}752 Hello, World!753754 In most cases it should be more convenient and efficient to use the755 ``%`` operator or :meth:`str.format`.756757 .. code-block:: text758759 {{ "%s, %s!" % (greeting, name) }}760 {{ "{}, {}!".format(greeting, name) }}761762 .. _printf-style: https://docs.python.org/library/stdtypes.html763 #printf-style-string-formatting764 """765 if args and kwargs:766 raise FilterArgumentError('can\'t handle positional and keyword '767 'arguments at the same time')
515 unmodified lines