escape Filter

Coding

Documentation

Escapes HTML characters.

Variable

blurb = '<p>You are <em>pretty</em> smart!</p>'

Template

{% autoescape off %}
  <code>{{ blurb|escape }}</code> will output:
  {{ blurb }}
{% endautoescape %}

Result

<code>&lt;p&gt;You are &lt;em&gt;pretty&lt;/em&gt; smart!&lt;/p&gt;</code> will output:
<p>You are <em>pretty</em> smart!</p>

The browser output would be:

<p>You are <em>pretty</em> smart!</p> will output:

You are pretty smart!


Did we get something wrong? Is there a use case for the escape filter that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on April 15, 2020, 11:10 a.m. EST