transform
transform.CanHighlight
CanHighlight returns whether the given language is supported by the Chroma highlighter.
transform.Emojify
(s any) → template.HTML
Emojify returns a copy of s
with all emoji codes replaced with actual emojis.
See http://www.emoji-cheat-sheet.com/
Aliases: emojify
Examples
{{ "I :heart: Hugo" | emojify }}
I ❤️ Hugo
transform.HTMLEscape
HTMLEscape returns a copy of s
with reserved HTML characters escaped.
Aliases: htmlEscape
Examples
{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | safeHTML}}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>"}}
Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;
{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | htmlUnescape | safeHTML }}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
transform.HTMLUnescape
HTMLUnescape returns a copy of with HTML escape requences converted to plain text.
Aliases: htmlUnescape
Examples
{{ htmlUnescape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | safeHTML}}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{"Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlUnescape | htmlUnescape | safeHTML}}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{"Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlUnescape | htmlUnescape }}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{ htmlUnescape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | htmlEscape | safeHTML }}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
transform.Highlight
(s any, lang string, opts …any) → template.HTML
Highlight returns a copy of s
as an HTML string with syntax
highlighting applied.
Aliases: highlight
transform.HighlightCodeBlock
(ctx CodeblockContext, opts …any) → HightlightResult
HighlightCodeBlock highlights a code block on the form received in the codeblock render hooks.
transform.Markdownify
(s any) → template.HTML
Markdownify renders a given input from Markdown to HTML.
Aliases: markdownify
Examples
{{ .Title | markdownify}}
<strong>BatMan</strong>
transform.Plainify
Plainify returns a copy of s
with all HTML tags removed.
Aliases: plainify
Examples
{{ plainify "Hello <strong>world</strong>, gophers!" }}
Hello world, gophers!
transform.Remarshal
(format string, data any) → string
Remarshal is used in the Hugo documentation to convert configuration examples from YAML to JSON, TOML (and possibly the other way around). The is primarily a helper for the Hugo docs site. It is not a general purpose YAML to TOML converter etc., and may change without notice if it serves a purpose in the docs. Format is one of json, yaml or toml.
Examples
{{ "title = \"Hello World\"" | transform.Remarshal "json" | safeHTML }}
{
"title": "Hello World"
}
transform.Reset
() →
transform.Unmarshal
Unmarshal unmarshals the data given, which can be either a string, json.RawMessage or a Resource. Supported formats are JSON, TOML, YAML, and CSV. You can optionally provide an options map as the first argument.
Aliases: unmarshal
Examples
{{ "hello = \"Hello World\"" | transform.Unmarshal }}
map[hello:Hello World]
{{ "hello = \"Hello World\"" | resources.FromString "data/greetings.toml" | transform.Unmarshal }}
map[hello:Hello World]