djangosnippets.org: Latest snippets tagged with 'removetags'https://djangosnippets.org/tags/removetags/2010-11-12T06:03:53.393540-06:00Analogue template filter to removetags that also removes the content of the tag
2010-11-12T06:03:53.393540-06:00piquadrathttps://djangosnippets.org/snippets/2257/<p>Django's builtin <code>removetags</code> filter removes the supplied tags, but leaves the enclosed text alone. Sometimes you need the complete tag, including its content to go away. Example:
</p>
<pre><code><h1>Some headline</h1>
<p>Some text</p>
</code></pre><p>Applying <code>removetags:"h1"</code> to this html results in
</p>
<pre><code>Some headline
<p>Some text</p>
</code></pre><p>while <code>killtags:"h1"</code> leaves
</p>
<pre><code><p>Some text</p>
</code></pre>
Freely redistributable