djangosnippets.org: Latest snippets tagged with 'escape'https://djangosnippets.org/tags/escape/2008-01-20T18:56:20.515627-06:00htmlentities
2008-01-20T18:56:20.515627-06:00pytechdhttps://djangosnippets.org/snippets/556/<p>The built-in escape filter only works with certain characters. It works great in environments where you can declare your charset (UTF-8). However, not everything can handle anything outside of the ASCII charset.
</p>
<p>This replaces all non-ASCII characters with their encoded value as <code>&#174;</code> for ®, for example.
</p>
Freely redistributablekeeptags: strip all HTML tags from output except a specified list of elements
2007-06-24T18:17:13.786838-05:00chrominancehttps://djangosnippets.org/snippets/295/<p>Django has several filters designed to sanitize HTML output, but they're either too broad (striptags, escape) or too narrow (removetags) to use when you want to allow a specified set of HTML tags in your output. Thus keeptags was born. Some of the code is essentially ripped from the Django …</p>
Freely redistributableescape() -- works on dictionaries/lists
2007-05-17T15:43:28.446200-05:00zeeghttps://djangosnippets.org/snippets/241/<p>Works just like the normal template filter, escape(), except that it works on dictionaries and lsits</p>
Freely redistributable