Debian Codegraph @

docs/content/en/functions/transform/HTMLEscape.md

raw
1 ---
2 title: transform.HTMLEscape
3 description: Returns the given string, escaping special characters by replacing them with HTML entities.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [htmlEscape]
9 returnType: string
10 signatures: [transform.HTMLEscape INPUT]
11 aliases: [/functions/htmlescape]
12 ---
13
14 The `transform.HTMLEscape` function escapes five special characters by replacing them with [HTML entities][]:
15
16 - `&` → `&`
17 - `<` → `&lt;`
18 - `>` → `&gt;`
19 - `'` → `&#39;`
20 - `"` → `&#34;`
21
22 For example:
23
24 ```go-html-template
25 {{ htmlEscape "Lilo & Stitch" }} → Lilo &amp; Stitch
26 {{ htmlEscape "7 > 6" }} → 7 &gt; 6
27 ```
28
29 [HTML entities]: https://developer.mozilla.org/en-US/docs/Glossary/Entity