title |
---|
Templating |
{{"{{< lead >}}"}}
Generally speaking the templating uses Golang text/template
template syntax. All fields with templating enabled do support the full synax from the text/template
package.
{{"{{< /lead >}}"}}
There are certain variables available in the strings with templating enabled:
channel
- Channel the message was sent to, only available for regular messages not eventsmsg
- The message object, used in functions, should not be sent to chatpermitTimeout
- Value ofpermit_timeout
in secondsusername
- The username of the message author
Within templates following functions can be used:
- built-in functions in
text/template
engine - functions from sprig function collection
- functions mentioned below
Examples below are using this syntax in the code block:
! Message matcher used for the input message
> Input message if used in the example
# Template used in the fields
< Output from the template (Rendered during docs generation)
* Output from the template (Static output, template not rendered)
{{ range .Funcs -}}
{{ .Description }}
Syntax: {{ .Syntax }}
{{- if .Example }}
Example:
{{- if .Example.MatchMessage }}
! {{ .Example.MatchMessage }}
{{- end }}
{{- if .Example.MessageContent }}
> {{ .Example.MessageContent }}
{{- end }}
# {{ .Example.Template }}
{{- if .Example.FakedOutput }}
* {{ .Example.FakedOutput }}
{{- else }}
< {{ renderExample .Example }}
{{- end }}
{{- end }}
{{ if .Remarks -}} {{ .Remarks }}
{{ end -}} {{- end -}}
{{ if false }}{{ end }}