transform.XMLEscape
Returns the given string, removing disallowed characters then escaping the result to its XML equivalent.
- Syntax
- transform.XMLEscape INPUT
- Returns
- string
The transform.XMLEscape function removes disallowed characters as defined in the XML specification, then escapes the result by replacing the following characters with HTML entities:
"→"'→'&→&<→<>→>\t→	\n→
\r→
For example:
{{ transform.XMLEscape "<p>abc</p>" }} → <p>abc</p>When using transform.XMLEscape in a template rendered by Go’s html/template package, declare the string to be safe HTML to avoid double escaping. For example, in an RSS template:
layouts/rss.xml
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>Last updated:
June 18, 2026
:
Merge commit 'c86d9f4aa8a58931f52df6516f10b67c807505fb' (be780afa7)
Improve this page