1aerc-templates(7)      Miscellaneous Information Manual      aerc-templates(7)
2
3
4

NAME

6       aerc-templates - template file specification for aerc(1)
7

SYNOPSIS

9       aerc uses the go "text/template" package for the template parsing. Re‐
10       fer to the go text/template documentation for the general syntax.
11
12       Template files are composed of headers, followed by a newline, followed
13       by the body text.
14
15       Example:
16
17           X-Clacks-Overhead: GNU Terry Pratchett
18
19           Hello,
20
21           Greetings,
22           Chuck
23
24       If you have a template that doesn't add any header, it must be preceded
25       by a newline, to avoid parsing parts of the body as header text.
26
27       All headers defined in the template will have precedence over any head‐
28       ers that are initialized by aerc (e.g. Subject, To, From, Cc) when com‐
29       posing a new message, forwarding or replying.
30

MESSAGE DATA

32       The following data can be used in templates. Though they are not all
33       available always.
34
35       Addresses
36           An array of mail.Address. That can be used to add sender or recipi‐
37           ent names to the template.
38
39           •   From: List of senders.
40           •   To: List of To recipients. Not always Available.
41           •   Cc: List of Cc recipients. Not always Available.
42           •   Bcc: List of Cc recipients. Not always Available.
43           •   OriginalFrom: List of senders of the original message. Avail‐
44               able for quoted reply and forward.
45
46
47           Example:
48
49           Get the name of the first sender.
50               {{(index .From 0).Name}}
51
52           Get the email address of the first sender.
53               {{(index .From 0).Address}}
54
55       Date and Time
56           The date and time information is always available and can be easily
57           formatted.
58
59           •   Date: Date and Time information when the compose window is
60               opened.
61           •   OriginalDate: Date and Time when the original message of re‐
62               ceived. Available for quoted reply and forward.
63
64
65           To format the date fields, dateFormat and toLocal are provided. Re‐
66           fer to the TEMPLATE FUNCTIONS section for details.
67
68       Subject
69           The subject of the email is available for quoted reply and forward.
70
71           {{.Subject}}
72
73       MIME Type
74           MIME Type is available for quoted reply and forward.
75
76           •   OriginalMIMEType: MIME type info of quoted mail part. Usually
77               "text/plain" or "text/html".
78
79
80       Original Message
81           When using quoted reply or forward, the original message is avail‐
82           able in a field called ".OriginalText".
83
84               {{.OriginalText}}
85

TEMPLATE FUNCTIONS

87       Besides the standard functions described in go's text/template documen‐
88       tation, aerc provides the following additional functions:
89
90       wrap
91           Wrap the original text to the specified number of characters per
92           line.
93
94               {{wrap 72 .OriginalText}}
95
96       quote
97           Prepends each line with "> ".
98
99               {{quote .OriginalText}}
100
101       exec
102           Execute external command, provide the second argument to its stdin.
103
104               {{exec `/usr/local/share/aerc/filters/html` .OriginalText}}
105
106       toLocal
107           Convert the date to the local timezone as specified by the locale.
108
109               {{toLocal .Date}}
110
111       dateFormat
112           Format date and time according to the format passed as the second
113           argument. The format must be specified according to go's time pack‐
114           age format.
115
116               {{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
117
118       version
119           Returns the version of aerc, which can be useful for things like X-
120           Mailer.
121
122               X-Mailer: aerc {{version}}
123
124       Function chaining
125           All of the template functions can be chained together if needed.
126
127           Example: Automatic HTML parsing for text/html mime type messages
128               {{if eq .OriginalMIMEType "text/html"}}
129               {{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
130               {{else}}
131               {{wrap 72 .OriginalText | quote}}
132               {{end}}
133

SEE ALSO

135       aerc(1) aerc-config(5)
136

AUTHORS

138       Originally created by Drew DeVault <sir@cmpwn.com> and maintained by
139       Robin Jarry <robin@jarry.cc> who is assisted by other open source con‐
140       tributors. For more information about aerc development, see
141       https://sr.ht/~rjarry/aerc/.
142
143
144
145                                  2022-06-18                 aerc-templates(7)
Impressum