Skip to main content

escape

Escapes a string by replacing HTML special characters with escape sequences. It doesn’t change strings that don’t have anything to escape.

escape_once

Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escape.

strip_html

Removes any HTML tags from a string.

newline_to_br

Replaces every newline (\n) in a string with an HTML line break (“).

url_encode

Converts any URL-unsafe characters in a string into percent-encoded characters.

url_decode

Decodes a string that has been encoded as a URL.

xml_escape

Escape some text for use in XML.

cgi_escape

CGI escape a string for use in a URL. Replaces any special characters with appropriate %XX replacements. CGI escape normally replaces a space with a plus + sign.

uri_escape

Percent encodes any special characters in a URI. URI escape normally replaces a space with %20. Reserved characters will not be escaped.

slugify

Convert a string into a lowercase URL “slug”. The slugify filter accepts 2 options:
  1. mode: string. The default is "default". They are as follows (with what they filter):
  • "none": no characters
  • "raw": spaces
  • "default": spaces and non-alphanumeric characters
  • "pretty": spaces and non-alphanumeric characters except for ._~!$&'()+,;=@
  • "ascii": spaces, non-alphanumeric, and non-ASCII characters
  • "latin": like default, except Latin characters are first transliterated (e.g. àèïòü to aeiou).
  1. case: boolean. The default is false. The original case of slug will be retained if set to true.