Snippet List
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.
This replaces all non-ASCII characters with their encoded value as `®` for ®, for example.
- escape
- htmlentities
- ascii
Sorts a list of HTML anchor tags based on the anchor's contents. This is useful, for example, when combining a static list of links with a dynamic list that needs to be sorted alphabetically. It ignores all attributes of the HTML anchor.
{% load anchorsort %}
{% anchorsort %}
<a href="afoo.jpg">Trip to Fiji</a>
<a href="bfoo.jpg">Doe, a deer, a female deer!</a>
{% for link in links %}
<a class="extra" href="{{ link.href|escape }}">{{ link.name|escape }}</a>
{% endfor %}
{% endanchorsort %}
Note that case (capital vs. lower) is ignored. Any HTMl within the node itself **will not be removed**, so sorting `<a>Bar</a><a><strong>Foo</strong><a/>` will sort as `<a><strong>Foo</strong></a><a>Bar</a>` because `<` is logically less than `b`.
pytechd has posted 2 snippets.