def conditional_escape(html): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. """ if hasattr(html, '__html__'): return html.__html__() else: return django.utils.html.escape(html)
def conditional_escape(html): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. """ if hasattr(html, '__html__'): return html.__html__() else: return django.utils.html.escape(html)
def conditional_escape(html): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. """ if hasattr(html, '__html__'): return html.__html__() elif isinstance(html, django.utils.safestring.SafeData): return html return django.utils.html.escape(html)
def conditional_escape(html): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. """ if hasattr(html, '__html__'): return html.__html__() elif isinstance(html, django.utils.safestring.SafeData): return html return django.utils.html.escape(html)