#35668: Expand format_html_join() to allow keyword formatting
------------------------------+---------------------------------------
Reporter: Adam Johnson | Type: New feature
Status: new | Component: Utilities
Version: dev | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
[
https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.html.format_html_join
`format_html_join()`] currently allows formatting positional arguments
only. It would be nice if it expanded support to allow keyword arguments,
like the underlying `format_html()` does. Keyword arguments would come
from an iterable of mappings (dicts and dict-like objects). This would
allow less repetition when a value is used multiple times in the template
string, like:
{{{
from django.utils.html import format_html_join
html = format_html_join(
"\n",
'<li data-id="{id}">{title} ({id})</li>',
[
{"id":
book.id, "title": book.title}
for book in books
]
)
}}}
and even:
{{{
from django.utils.html import format_html_join
html = format_html_join(
"\n",
'<li data-id="{id}">{title} ({id})</li>',
Book.objects.values("id", "title")
)
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/35668>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.