mirror of
https://github.com/django/django.git
synced 2025-08-31 07:47:37 +00:00
Fixed #26483 -- Updated docs.python.org links to use Intersphinx.
This commit is contained in:
parent
413f3bb5c8
commit
f5ff5010cd
20 changed files with 75 additions and 108 deletions
|
@ -618,14 +618,14 @@ escaping HTML.
|
|||
|
||||
.. function:: format_html(format_string, *args, **kwargs)
|
||||
|
||||
This is similar to `str.format`_, except that it is appropriate for
|
||||
This is similar to :meth:`str.format`, except that it is appropriate for
|
||||
building up HTML fragments. All args and kwargs are passed through
|
||||
:func:`conditional_escape` before being passed to ``str.format``.
|
||||
:func:`conditional_escape` before being passed to ``str.format()``.
|
||||
|
||||
For the case of building up small HTML fragments, this function is to be
|
||||
preferred over string interpolation using ``%`` or ``str.format`` directly,
|
||||
because it applies escaping to all arguments - just like the Template system
|
||||
applies escaping by default.
|
||||
preferred over string interpolation using ``%`` or ``str.format()``
|
||||
directly, because it applies escaping to all arguments - just like the
|
||||
template system applies escaping by default.
|
||||
|
||||
So, instead of writing::
|
||||
|
||||
|
@ -642,14 +642,12 @@ escaping HTML.
|
|||
This has the advantage that you don't need to apply :func:`escape` to each
|
||||
argument and risk a bug and an XSS vulnerability if you forget one.
|
||||
|
||||
Note that although this function uses ``str.format`` to do the
|
||||
interpolation, some of the formatting options provided by `str.format`_
|
||||
Note that although this function uses ``str.format()`` to do the
|
||||
interpolation, some of the formatting options provided by ``str.format()``
|
||||
(e.g. number formatting) will not work, since all arguments are passed
|
||||
through :func:`conditional_escape` which (ultimately) calls
|
||||
:func:`~django.utils.encoding.force_text` on the values.
|
||||
|
||||
.. _str.format: https://docs.python.org/library/stdtypes.html#str.format
|
||||
|
||||
.. function:: format_html_join(sep, format_string, args_generator)
|
||||
|
||||
A wrapper of :func:`format_html`, for the common case of a group of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue