'noescape' filter for django template

80 views
Skip to first unread message

Hangyu Zhang

unread,
Jan 25, 2016, 10:12:17 AM1/25/16
to Django developers (Contributions to Django itself)
Hi All,

I want to add a new filter names 'noescape'  to django template. After that,

{{ <context variable>|noescape }}

will output the context variable without auto escape.

It will be more convenient than

{% autoescape off %}{{ <context variable> }} {% endautoescape %}

Thanks and regards,

Hans

Tim Graham

unread,
Jan 25, 2016, 10:33:01 AM1/25/16
to Django developers (Contributions to Django itself)
Is there some reason you cannot mark the string safe in Python code using one of the following methods? I think that's where escaping logic belongs.

https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.html.format_html
https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.safestring.mark_safe

Florian Apolloner

unread,
Jan 25, 2016, 11:48:49 AM1/25/16
to Django developers (Contributions to Django itself)
And even then, |safe is exactly the same as |noescape
Reply all
Reply to author
Forward
0 new messages