AERC-TEMPLATES(7) | Miscellaneous Information Manual | AERC-TEMPLATES(7) |
aerc-templates - template file specification for aerc(1)
aerc uses the go text/template package for the template parsing. Refer to the go text/template documentation for the general syntax.
Template files are composed of headers, followed by a newline, followed by the body text.
Example:
X-Clacks-Overhead: GNU Terry Pratchett Hello, Greetings, Chuck
If you have a template that doesn't add any header, it must be preceded by a newline, to avoid parsing parts of the body as header text.
All headers defined in the template will have precedence over any headers that are initialized by aerc (e.g. Subject, To, From, Cc) when composing a new message, forwarding or replying.
The following data can be used in templates. Though they are not all available always.
Addresses
Example:
Get the name of the first sender.
{{(index .From 0).Name}}
Get the email address of the first sender.
{{(index .From 0).Address}}
Date and Time
To format the date fields, dateFormat and toLocal are provided. Refer to the TEMPLATE FUNCTIONS section for details.
Subject
{{.Subject}}
MIME Type
Original Message
{{.OriginalText}}
Besides the standard functions described in go's text/template documentation, aerc provides the following additional functions:
wrap
{{wrap 72 .OriginalText}}
quote
{{quote .OriginalText}}
exec
{{exec `/usr/local/share/aerc/filters/html` .OriginalText}}
toLocal
{{toLocal .Date}}
dateFormat
{{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
version
X-Mailer: aerc {{version}}
Function chaining
Example: Automatic HTML parsing for text/html mime type messages
{{if eq .OriginalMIMEType "text/html"}} {{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}} {{else}} {{wrap 72 .OriginalText | quote}} {{end}}
Originally created by Drew DeVault <sir@cmpwn.com> and maintained by Robin Jarry <robin@jarry.cc> who is assisted by other open source contributors. For more information about aerc development, see https://sr.ht/~rjarry/aerc/.
2023-04-23 |