HUGO
Menu
GitHub 90265 stars Mastodon

transform.Plainify

Returns the given input with all HTML tags removed.
Syntax
transform.Plainify INPUT
Returns
any
Alias
plainify

Usage

The transform.Plainify function returns the given input with all HTML tags removed.

New in v0.169.0

The return type depends on the type of INPUT. If INPUT is of type template.HTML, the function returns template.HTML. Otherwise, it returns a string.

When you print a string result in an HTML template, Hugo escapes HTML entities in the result again. To prevent this, pass a template.HTML value as INPUT, such as the result of the safe.HTML function. See safe types for details.

Examples

{{ transform.Plainify "<b>BatMan</b>" }} → BatMan

Comparing string and template.HTML input, showing the raw HTML output:

{{ "<b>Lilo &amp; Stitch</b>" | transform.Plainify }} → Lilo &amp;amp; Stitch
{{ "<b>Lilo &amp; Stitch</b>" | safeHTML | transform.Plainify }} → Lilo &amp; Stitch