mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Added 'format_html' utility for formatting HTML fragments safely
This commit is contained in:
parent
f33e150369
commit
bee498f3a2
3 changed files with 81 additions and 0 deletions
|
@ -34,6 +34,17 @@ class TestUtilsHtml(unittest.TestCase):
|
|||
# Verify it doesn't double replace &.
|
||||
self.check_output(f, '<&', '<&')
|
||||
|
||||
def test_format_html(self):
|
||||
self.assertEqual(
|
||||
html.format_html(u"{0} {1} {third} {fourth}",
|
||||
u"< Dangerous >",
|
||||
html.mark_safe(u"<b>safe</b>"),
|
||||
third="< dangerous again",
|
||||
fourth=html.mark_safe(u"<i>safe again</i>")
|
||||
),
|
||||
u"< Dangerous > <b>safe</b> < dangerous again <i>safe again</i>"
|
||||
)
|
||||
|
||||
def test_linebreaks(self):
|
||||
f = html.linebreaks
|
||||
items = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue