Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
f33e1503
Kaydet (Commit)
f33e1503
authored
Haz 30, 2012
tarafından
Luke Plant
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Documented utils.html.escape and conditional_escape
üst
cf731a54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
html.py
django/utils/html.py
+7
-7
utils.txt
docs/ref/utils.txt
+22
-0
No files found.
django/utils/html.py
Dosyayı görüntüle @
f33e1503
...
...
@@ -31,11 +31,11 @@ hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|
trailing_empty_content_re
=
re
.
compile
(
r'(?:<p>(?: |\s|<br \/>)*?</p>\s*)+\Z'
)
del
x
# Temporary variable
def
escape
(
html
):
def
escape
(
text
):
"""
Returns the given
HTML with ampersands, quotes and angle brackets encoded
.
Returns the given
text with ampersands, quotes and angle brackets encoded for use in HTML
.
"""
return
mark_safe
(
force_unicode
(
html
)
.
replace
(
'&'
,
'&'
)
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
.
replace
(
'"'
,
'"'
)
.
replace
(
"'"
,
'''
))
return
mark_safe
(
force_unicode
(
text
)
.
replace
(
'&'
,
'&'
)
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
.
replace
(
'"'
,
'"'
)
.
replace
(
"'"
,
'''
))
escape
=
allow_lazy
(
escape
,
unicode
)
_base_js_escapes
=
(
...
...
@@ -63,14 +63,14 @@ def escapejs(value):
return
value
escapejs
=
allow_lazy
(
escapejs
,
unicode
)
def
conditional_escape
(
html
):
def
conditional_escape
(
text
):
"""
Similar to escape(), except that it doesn't operate on pre-escaped strings.
"""
if
isinstance
(
html
,
SafeData
):
return
html
if
isinstance
(
text
,
SafeData
):
return
text
else
:
return
escape
(
html
)
return
escape
(
text
)
def
linebreaks
(
value
,
autoescape
=
False
):
"""Converts newlines into <p> and <br />s."""
...
...
docs/ref/utils.txt
Dosyayı görüntüle @
f33e1503
...
...
@@ -387,6 +387,28 @@ Atom1Feed
input is a proper string, then add support for lazy translation objects at the
end.
``django.utils.html``
=====================
.. module:: django.utils.html
:synopsis: HTML helper functions
Usually you should build up HTML using Django's templates to make use of its
autoescape mechanism, using the utilities in :mod:`django.utils.safestring`
where appropriate. This module provides some additional low level utilitiesfor
escaping HTML.
.. function:: escape(text)
Returns the given text with ampersands, quotes and angle brackets encoded
for use in HTML. The input is first passed through
:func:`~django.utils.encoding.force_unicode` and the output has
:func:`~django.utils.safestring.mark_safe` applied.
.. function:: conditional_escape(text)
Similar to ``escape()``, except that it doesn't operate on pre-escaped strings,
so it will not double escape.
``django.utils.http``
=====================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment