MCPcopy
hub / github.com/django/django / conditional_escape

Function conditional_escape

django/utils/html.py:120–132  ·  django/utils/html.py::conditional_escape

Similar to escape(), except that it doesn't operate on pre-escaped strings. This function relies on the __html__ convention used both by Django's SafeData class and by third-party libraries like markupsafe.

(text)

Source from the content-addressed store, hash-verified

118
119
120def conditional_escape(text):
121 class="st">"""
122 Similar to escape(), except that it doesn&class="cm">#x27;t operate on pre-escaped strings.
123
124 This function relies on the __html__ convention used both by Django&class="cm">#x27;s
125 SafeData class and by third-party libraries like markupsafe.
126 class="st">"""
127 if isinstance(text, Promise):
128 text = str(text)
129 if hasattr(text, class="st">"__html__"):
130 return text.__html__()
131 else:
132 return escape(text)
133
134
135def format_html(format_string, *args, **kwargs):

Callers 14

label_tagMethod · 0.90
contentsMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
render_value_in_contextFunction · 0.90
escape_filterFunction · 0.90
escapeseqFunction · 0.90
joinFunction · 0.90
renderMethod · 0.90
renderMethod · 0.90

Calls 2

escapeFunction · 0.85
__html__Method · 0.45