1aerc-templates(7) Miscellaneous Information Manual aerc-templates(7)
2
3
4
6 aerc-templates - template file specification for aerc(1)
7
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
28 The following data can be used in templates. Though they are not all
29 available always.
30
31 Addresses
32 An array of mail.Address. That can be used to add sender or recipi‐
33 ent names to the template.
34
35 • From: List of senders.
36 • To: List of To recipients. Not always Available.
37 • Cc: List of Cc recipients. Not always Available.
38 • Bcc: List of Cc recipients. Not always Available.
39 • OriginalFrom: List of senders of the original message. Avail‐
40 able for quoted reply and forward.
41
42
43 Example:
44
45 Get the name of the first sender.
46 {{(index .From 0).Name}}
47
48 Get the email address of the first sender.
49 {{(index .From 0).Address}}
50
51 Date and Time
52 The date and time information is always available and can be easily
53 formatted.
54
55 • Date: Date and Time information when the compose window is
56 opened.
57 • OriginalDate: Date and Time when the original message of re‐
58 ceived. Available for quoted reply and forward.
59
60
61 To format the date fields, dateFormat and toLocal are provided. Re‐
62 fer to the TEMPLATE FUNCTIONS section for details.
63
64 Subject
65 The subject of the email is available for quoted reply and forward.
66
67 {{.Subject}}
68
69 MIME Type
70 MIME Type is available for quoted reply and forward.
71
72 • OriginalMIMEType: MIME type info of quoted mail part. Usually
73 "text/plain" or "text/html".
74
75
76 Original Message
77 When using quoted reply or forward, the original message is avail‐
78 able in a field called ".OriginalText".
79
80 {{.OriginalText}}
81
83 Besides the standard functions described in go's text/template documen‐
84 tation, aerc provides the following additional functions:
85
86 wrap
87 Wrap the original text to the specified number of characters per
88 line.
89
90 {{wrap 72 .OriginalText}}
91
92 quote
93 Prepends each line with "> ".
94
95 {{quote .OriginalText}}
96
97 exec
98 Execute external command, provide the second argument to its stdin.
99
100 {{exec `/usr/local/share/aerc/filters/html` .OriginalText}}
101
102 toLocal
103 Convert the date to the local timezone as specified by the locale.
104
105 {{toLocal .Date}}
106
107 dateFormat
108 Format date and time according to the format passed as the second
109 argument. The format must be specified according to go's time pack‐
110 age format.
111
112 {{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
113
114 version
115 Returns the version of aerc, which can be useful for things like X-
116 Mailer.
117
118 X-Mailer: aerc {{version}}
119
120 Function chaining
121 All of the template functions can be chained together if needed.
122
123 Example: Automatic HTML parsing for text/html mime type messages
124 {{if eq .OriginalMIMEType "text/html"}}
125 {{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
126 {{else}}
127 {{wrap 72 .OriginalText | quote}}
128 {{end}}
129
131 aerc(1) aerc-config(5)
132
134 Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other
135 open source contributors. For more information about aerc development,
136 see https://git.sr.ht/~sircmpwn/aerc.
137
138
139
140 2021-07-21 aerc-templates(7)