Template helpers
The Handlebars and Go template engines provide built-in helpers. Mustache and static templates do not.
Live examples: the helpers_handlebars and helpers_go_template templates in
the Gallery.
format_time
Formats an ISO-8601 (RFC 3339) timestamp using a strftime pattern.
{{/* Go — positional or piped */}}
{{format_time "%Y-%m-%dT%H:%M:%S%z" .from_time}}
{{.from_time | format_time "%Y-%m-%dT%H:%M:%S%z"}}
In Handlebars a bad input surfaces as a helper error; in Go it returns an error from the pipeline.
markdown
Renders a Markdown string to HTML and returns it as safe (unescaped) HTML.
{{markdown .description}}
{{.description | markdown}}
Security:
markdownoutput is not HTML-escaped, and the renderer does not strip embedded HTML. Never pass untrusted data tomarkdownwithout sanitising it. See Security model.
embed_text
Reads a file from the template's assets/ directory and inlines its text
content — handy for inlining CSS.
embed_base64
Reads an asset and returns its base64 encoding — handy for inlining images as data URIs.
Paths are relative to the template's assets/ directory.
equal (Handlebars only)
A block helper that renders its block when two stringified values are equal, with
an {{else}} inverse.
Helper availability
| Helper | Handlebars | Go | Mustache | Static |
|---|---|---|---|---|
format_time | ✓ | ✓ | ||
markdown | ✓ | ✓ | ||
embed_text | ✓ | ✓ | ||
embed_base64 | ✓ | ✓ | ||
equal | ✓ |