.Plain
is the Page content stripped of HTML tags as a string.
.PlainWords
is the Page content stripped of HTML as a []string (string slice). Under the hood, we’re using Go’s strings.Fields to split .Plain
into a slice.
.RawContent
is the raw content read from the content file. Generally, this would be the raw Markdown content prior to any encoding from Hugo.
plainify
is a template function that takes a given input, strips it of HTML tags, and returns a string.
jsonify
is a template function that takes a given object, encodes it as JSON, and converts it to HTML-safe content.
The safe*
family takes a given input and does a type-casting to the thing you want. For example, safeHTML
can take a string
as input, but returns a template.HTML
type. Go HTML templates are context-aware. If you try to print a string
with HTML tags in an HTML context, Go will escape all of the HTML tags. In that case, you need to convert the string
type to template.HTML
so that Go will leave it alone.