Strip HTML from Django template block?
<p>In my Django <code>base.html</code> template I have a <code>title</code> block:</p>

<pre class="lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;{% block title %}{% endblock %}&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        {% block content %}
        {% endblock %}
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>In a page template I use the text from its <code>&lt;h1&gt;</code> page title in that block, so it also appears in the <code>&lt;title&gt;</code> tag, e.g.:</p>

<pre class="lang-html prettyprint-override"><code>{% extends 'base.html' %}

{% block content %}
    &lt;h1&gt;{% block title %}Hello world!{% endblock %}&lt;/h1&gt;
{% endblock %}
</code></pre>

<p>That all works fine. But if I want to use HTML tags within the page's <code>&lt;h1&gt;</code> like this...</p>

<pre class="lang-html prettyprint-override"><code>{% extends 'base.html' %}

{% block content %}
    {% block title %}&lt;b&gt;Hello&lt;/b&gt; world!{% endblock %}
{% endblock %}
</code></pre>

<p>...those tags will also appear in the <code>&lt;title&gt;</code>, which isn't allowed.</p>

<p>Is there a way around this other than having two versions of the title: one within <code>&lt;h1&gt;</code>, and one HTML-free version within a <code>{% block title %}</code>? I don't <em>think</em> there's a way to strip HTML from a block?</p>