Skip to main content

html_safe

A decorator that defines the html method. This helps non-Django templates to detect classes whose str methods return SafeString.

def html_safe(
klass: class
) - > class

A decorator that defines the html method. This helps non-Django templates to detect classes whose str methods return SafeString.

Parameters

NameTypeDescription
klassclassThe class to be decorated, which must implement str but not html

Returns

TypeDescription
classThe modified class with html implemented and str wrapped to return a SafeString