Gopher

transform

Transform is Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

transform.CanHighlight  

(lang string) → bool

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  

(s any) → string

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 &amp; The Sunshine Band &lt;cathal@foo.bar&gt;
{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>"}}
Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;
{{ htmlEscape "Cathal Garvey & The Sunshine Band <cathal@foo.bar>" | htmlUnescape | safeHTML }}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>

transform.HTMLUnescape  

(s any) → string

HTMLUnescape returns a copy of with HTML escape requences converted to plain text.

Aliases: htmlUnescape

Examples

{{ htmlUnescape "Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | safeHTML}}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{"Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;" | htmlUnescape | htmlUnescape | safeHTML}}
Cathal Garvey & The Sunshine Band <cathal@foo.bar>
{{"Cathal Garvey &amp;amp; The Sunshine Band &amp;lt;cathal@foo.bar&amp;gt;" | htmlUnescape | htmlUnescape }}
Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;
{{ htmlUnescape "Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;" | htmlEscape | safeHTML }}
Cathal Garvey &amp; The Sunshine Band &lt;cathal@foo.bar&gt;

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  

(s any) → string

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  

(args …any) → any

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]