summaryrefslogtreecommitdiff
path: root/django/utils/html.py
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2012-06-30 16:41:51 +0100
committerLuke Plant <L.Plant.98@cantab.net>2012-07-03 22:20:12 +0100
commitf33e15036907d6e4bda6116dc84097e9e590d2c8 (patch)
treeabd43daa68553d846e2d7e7832912ab72eb963c0 /django/utils/html.py
parentcf731a543eaae43f989f237727411763c386af1b (diff)
Documented utils.html.escape and conditional_escape
Diffstat (limited to 'django/utils/html.py')
-rw-r--r--django/utils/html.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index 014d837bbb..fe2e6b7a29 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -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>(?:&nbsp;|\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('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;'))
+ return mark_safe(force_unicode(text).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;'))
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."""