mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #35668 -- Added mapping support to format_html_join.
This commit is contained in:
@@ -10,6 +10,7 @@ from django.utils.html import (
|
||||
escape,
|
||||
escapejs,
|
||||
format_html,
|
||||
format_html_join,
|
||||
html_safe,
|
||||
json_script,
|
||||
linebreaks,
|
||||
@@ -75,6 +76,26 @@ class TestUtilsHtml(SimpleTestCase):
|
||||
name = "Adam"
|
||||
self.assertEqual(format_html(f"<i>{name}</i>"), "<i>Adam</i>")
|
||||
|
||||
def test_format_html_join_with_positional_arguments(self):
|
||||
self.assertEqual(
|
||||
format_html_join(
|
||||
"\n",
|
||||
"<li>{}) {}</li>",
|
||||
[(1, "Emma"), (2, "Matilda")],
|
||||
),
|
||||
"<li>1) Emma</li>\n<li>2) Matilda</li>",
|
||||
)
|
||||
|
||||
def test_format_html_join_with_keyword_arguments(self):
|
||||
self.assertEqual(
|
||||
format_html_join(
|
||||
"\n",
|
||||
"<li>{id}) {text}</li>",
|
||||
[{"id": 1, "text": "Emma"}, {"id": 2, "text": "Matilda"}],
|
||||
),
|
||||
"<li>1) Emma</li>\n<li>2) Matilda</li>",
|
||||
)
|
||||
|
||||
def test_linebreaks(self):
|
||||
items = (
|
||||
("para1\n\npara2\r\rpara3", "<p>para1</p>\n\n<p>para2</p>\n\n<p>para3</p>"),
|
||||
|
||||
Reference in New Issue
Block a user