MCPcopy
hub / github.com/django/django / mark_safe

Function mark_safe

django/utils/safestring.py:65–78  ·  view source on GitHub ↗

Explicitly mark a string as safe for (HTML) output purposes. The returned object can be used everywhere a string is appropriate. If used on a method as a decorator, mark the returned data as safe. Can be called multiple times on a single string.

(s)

Source from the content-addressed store, hash-verified

63
64@keep_lazy(SafeString)
65def mark_safe(s):
66 """
67 Explicitly mark a string as safe for (HTML) output purposes. The returned
68 object can be used everywhere a string is appropriate.
69
70 If used on a method as a decorator, mark the returned data as safe.
71
72 Can be called multiple times on a single string.
73 """
74 if hasattr(s, "__html__"):
75 return s
76 if callable(s):
77 return _safety_decorator(mark_safe, s)
78 return SafeString(s)

Callers 15

render_flatpageFunction · 0.90
ordinalFunction · 0.90
process_messagesMethod · 0.90
parse_rstFunction · 0.90
strip_p_tagsFunction · 0.90
errorsMethod · 0.90
label_tagMethod · 0.90
errorsMethod · 0.90
truncated_unordered_listFunction · 0.90
items_for_resultFunction · 0.90
result_hidden_fieldsFunction · 0.90

Calls 3

callableFunction · 0.85
_safety_decoratorFunction · 0.85
SafeStringClass · 0.85

Tested by 15

test_safedataMethod · 0.72
test_safedataMethod · 0.72
test_encoding_errorMethod · 0.72
test_empty_valueMethod · 0.72
test_safe_statusMethod · 0.72
test_format_htmlMethod · 0.72
test_mark_safeMethod · 0.72