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.
def conditional_escape(
text: Any
) - > string
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.
Parameters
| Name | Type | Description |
|---|---|---|
| text | Any | The input to be escaped, which may be a string, a lazy translation promise, or an object implementing the html protocol. |
Returns
| Type | Description |
|---|---|
string | The HTML-escaped string, or the original string if it is already marked as safe via the html method. |