mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #27753 -- Favored SafeString over SafeText.
This commit is contained in:
@@ -200,12 +200,12 @@ passed around inside the template code:
|
||||
to be interpreted as-is on the client side.
|
||||
|
||||
Internally, these strings are of type
|
||||
:class:`~django.utils.safestring.SafeText`. You can test for them
|
||||
:class:`~django.utils.safestring.SafeString`. You can test for them
|
||||
using code like::
|
||||
|
||||
from django.utils.safestring import SafeText
|
||||
from django.utils.safestring import SafeString
|
||||
|
||||
if isinstance(value, SafeText):
|
||||
if isinstance(value, SafeString):
|
||||
# Do something with the "safe" string.
|
||||
...
|
||||
|
||||
|
||||
@@ -748,14 +748,8 @@ appropriate entities.
|
||||
|
||||
.. class:: SafeString
|
||||
|
||||
A ``str`` subclass that has been specifically marked as "safe"
|
||||
(requires no further escaping) for HTML output purposes. Alias of
|
||||
:class:`SafeText`.
|
||||
|
||||
.. class:: SafeText
|
||||
|
||||
A ``str`` subclass that has been specifically marked as "safe" for HTML
|
||||
output purposes.
|
||||
A ``str`` subclass that has been specifically marked as "safe" (requires no
|
||||
further escaping) for HTML output purposes.
|
||||
|
||||
.. function:: mark_safe(s)
|
||||
|
||||
@@ -774,7 +768,7 @@ appropriate entities.
|
||||
>>> mystr = '<b>Hello World</b> '
|
||||
>>> mystr = mark_safe(mystr)
|
||||
>>> type(mystr)
|
||||
<class 'django.utils.safestring.SafeText'>
|
||||
<class 'django.utils.safestring.SafeString'>
|
||||
|
||||
>>> mystr = mystr.strip() # removing whitespace
|
||||
>>> type(mystr)
|
||||
|
||||
Reference in New Issue
Block a user