title: Remove HTML tags in Freemarker Template
body: <p>I've got a freemarker template that displays the same string in a context where HTML is allowed as well as a context where it is not.</p>
  
  <p>Is there a built-in in Freemarker that allows me to entirely remove HTML tags from a string?</p>
  
  <p>The following template (assuming there was a built-in <code>remove_html</code>)</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;#ftl output_format="HTML"/&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;${page_title?remove_html}&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;${page_title?no_esc}&lt;/h1&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the model <code>Collections.singletonMap("page_title", "A &lt;strong&gt;Strong&lt;/strong&gt; Argument")</code> should lead to</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;A Strong Argument&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;A &lt;strong&gt;Strong&lt;/strong&gt; Argument&lt;/h1&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Using the built-in <code>esc</code> would give me <code>&lt;title&gt;A &amp;lt;strong&amp;gt;Strong&amp;lt;/strong&amp;gt; Argument&lt;/title&gt;</code> instead, which is <em>not</em> what I am looking for.</p>
  
  <p>Is there something like <code>remove_html</code> or do I need to provide my own? (Using <a href="https://github.com/OWASP/java-html-sanitizer" rel="nofollow noreferrer">OWASP's java-html-sanitizer</a>, for instance.)</p>