transform.Emojify
- Syntax
- transform.Emojify INPUT
- Returns
- any
- Alias
- emojify
Usage
The transform.Emojify function returns the given input with emoji shortcodes replaced by their corresponding emoji characters. See the list of emoji shortcodes for available emoji.
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 elements in the result. To prevent this, pass a template.HTML value as INPUT, such as the result of the safe.HTML function. See safe types for details.
Use this function in templates. To replace emoji shortcodes in content files, set enableEmoji to true in your project configuration.
Examples
{{ transform.Emojify "I :heart: Hugo" }} → I ❤️ HugoComparing string and template.HTML input, showing the raw HTML output:
{{ "I :heart: <b>Hugo</b>" | transform.Emojify }} → I ❤️ <b>Hugo</b>
{{ "I :heart: <b>Hugo</b>" | safeHTML | transform.Emojify }} → I ❤️ <b>Hugo</b>