#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701913ae92218-6f1cddba-655f-46ed-823a-1415a7d68a66-000000%40eu-central-1.amazonses.com.

Reply via email to