HUGO
Menu
GitHub 90221 stars Mastodon

transform.HTMLUnescape

Returns the given string, replacing each HTML entity with its corresponding character.
Syntax
transform.HTMLUnescape INPUT
Returns
string
Alias
htmlUnescape

Usage

The transform.HTMLUnescape function returns the given string, replacing each HTML entity with its corresponding character.

The function returns a string. Go’s html/template package escapes strings in most contexts, which escapes the unescaped characters in the result again. To render the result as is, pass it through the safe.HTML function.

Examples

{{ transform.HTMLUnescape "Lilo & Stitch" }} → Lilo & Stitch
{{ transform.HTMLUnescape "7 > 6" }} → 7 > 6

Comparing the result with and without safe.HTML, showing the raw HTML output:

{{ transform.HTMLUnescape "Lilo & Stitch" }} → Lilo & Stitch
{{ transform.HTMLUnescape "Lilo & Stitch" | safeHTML }} → Lilo & Stitch