mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 00:22:09 -05:00
5fd1e74903
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
1.2 KiB
1.2 KiB
title | description | categories | keywords | action | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transform.XMLEscape | Returns the given string, removing disallowed characters then escaping the result to its XML equivalent. |
|
{{< new-in 0.121.0 >}}
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:
{{< code file="layouts/_default/rss.xml" >}} {{ .Summary | transform.XMLEscape | safeHTML }} {{< /code >}}