20. Template Functions
Output format templating is a powerful feature that allows you to control the look and feel (and, to some degree, content) of any information sent to users. Gort templates are based on Go templates, and support all of their features, including variables, logic, and flow control.
There are three main types of elements used to construct elements:
Tags: Tags (or “actions”) represents visual elements or directives, such as
{{ text }}
or{{ image }}
. All text and directives must be enclosed within (or between) tags.Functions: Functions are used to modify the contents or behavior of tags. They’re called using pipes (
|
) within a tag. For example,{{ image "foo.jpg" | thumbnail true }}
turns an image into a thumbnail image. Some functions can only be used with specific tags. Sprig functions are also supported.Fields: A call into a data value, typically the the Response Envelope.
The supported elements are detailed below.
20.2. Additional Functions
In addition to the above, all of the Sprig library functions are supported as well.