diff options
| author | nabil-rady <midorady9999@gmail.com> | 2024-08-14 00:58:37 +0300 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-08-20 08:20:34 +0200 |
| commit | 231c0d85931b5afde3e3caec0e6bc5ca6132bb7a (patch) | |
| tree | 8f7fbb7deb54c15507852eec31740f2a1a7adfbf /docs/ref/utils.txt | |
| parent | ca1318988c68f623ab12ab4ddb04eabb8afe5a33 (diff) | |
Fixed #35668 -- Added mapping support to format_html_join.
Diffstat (limited to 'docs/ref/utils.txt')
| -rw-r--r-- | docs/ref/utils.txt | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index d6c70a9bb0..33e0fceadf 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -699,10 +699,29 @@ escaping HTML. joined using ``sep``. ``sep`` is also passed through :func:`conditional_escape`. - ``args_generator`` should be an iterator that returns the sequence of - ``args`` that will be passed to :func:`format_html`. For example:: + ``args_generator`` should be an iterator that yields arguments to pass to + :func:`format_html`, either sequences of positional arguments or mappings of + keyword arguments. - format_html_join("\n", "<li>{} {}</li>", ((u.first_name, u.last_name) for u in users)) + For example, tuples can be used for positional arguments:: + + format_html_join( + "\n", + "<li>{} {}</li>", + ((u.first_name, u.last_name) for u in users), + ) + + Or dictionaries can be used for keyword arguments:: + + format_html_join( + "\n", + '<li data-id="{id}">{id} {title}</li>', + ({"id": b.id, "title": b.title} for b in books), + ) + + .. versionchanged:: 5.2 + + Support for mappings in ``args_generator`` was added. .. function:: json_script(value, element_id=None, encoder=None) |
