What does an XML Template escape content only in a <title> element?

I discovered some errors with my Atom feed template because an HTML encoded entity (&rsquo;) was not valid in XML. So I decided to put all my type="html element contents into CDATA blocks, and wrote this partial (I will eventually escape instances of []>) :

{{ printf "<![CDATA[%s]]>" . | safeHTML }}

It works great most of the time, for example:

<summary type="html">{{ partial "cdata.xml" .Title }}</summary>

Which properly outputs:

<summary type="html"><![CDATA[Hello there]]></summary >

Except when I use it in a <title> element:

<title type="html">{{ partial "cdata.xml" .Title }}</title>

When the output is:

<title type="html">&lt;![CDATA[Hello there]]&gt;</title>

Why does it escape the < and >? If I change it to titl it works. What’s so special about title? What’s the proper way to work around this? For now I’ve circumvented it with a printf:

{{ printf `<title type="html">%s</title>` (.Title | markdownify | partial "cdata.xml") | safeHTML }}

Which seems unfortunate TBH.

If you look at the default output format definitions, you can see that the RSS output format has isPlainText equal to false.

If you look at the configure output formats section…

isPlainText
use Go’s plain text templates parser for the templates. Default: false.

Which means that your RSS template is using Go’s html/template package. This package performs context-aware escaping in order to generate “HTML output safe against code injection.”

Ah, interesting, thank you. I have it set to isPlainText = false so that the HTML templates it uses work properly (it’s a full text feed, not just summaries).