docs: extract template function to their own section
The functions were located in the data section, which was suboptimal.
This commit is contained in:
parent
b03a73726d
commit
434eaa19a1
|
@ -7,7 +7,7 @@ aerc-templates - template file specification for *aerc*(1)
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
aerc uses the go "text/template" package for the template parsing.
|
aerc uses the go "text/template" package for the template parsing.
|
||||||
Refer to the go documentation for the general syntax.
|
Refer to the go text/template documentation for the general syntax.
|
||||||
|
|
||||||
Template files are composed of headers, followed by a newline, followed by the
|
Template files are composed of headers, followed by a newline, followed by the
|
||||||
body text.
|
body text.
|
||||||
|
@ -62,26 +62,12 @@ available always.
|
||||||
- OriginalDate: Date and Time when the original message of received.
|
- OriginalDate: Date and Time when the original message of received.
|
||||||
Available for quoted reply and forward.
|
Available for quoted reply and forward.
|
||||||
|
|
||||||
The _dateFormat_ function can be used to format the date and time.
|
To format the date fields, _dateFormat_ and _toLocal_ are provided.
|
||||||
|
Refer to the _TEMPLATE FUNCTIONS_ section for details.
|
||||||
The _toLocal_ function converts a time to the local time zone.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
Format the date to go's time package format options.
|
|
||||||
```
|
|
||||||
{{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
|
|
||||||
```
|
|
||||||
|
|
||||||
Format the date in the local time zone.
|
|
||||||
```
|
|
||||||
{{dateFormat (.Date | toLocal) "Mon Jan 2 15:04:05 -0700 MST 2006"}}
|
|
||||||
```
|
|
||||||
|
|
||||||
*Subject*
|
*Subject*
|
||||||
The subject of the email is available for quoted reply and forward.
|
The subject of the email is available for quoted reply and forward.
|
||||||
|
|
||||||
Example:
|
|
||||||
{{.Subject}}
|
{{.Subject}}
|
||||||
|
|
||||||
*MIME Type*
|
*MIME Type*
|
||||||
|
@ -91,33 +77,58 @@ available always.
|
||||||
"text/plain" or "text/html".
|
"text/plain" or "text/html".
|
||||||
|
|
||||||
*Original Message*
|
*Original Message*
|
||||||
When using quoted reply or forward, the original message is available.
|
When using quoted reply or forward, the original message is available in a
|
||||||
It can be used using two functions that are available to templates.
|
field called ".OriginalText".
|
||||||
|
|
||||||
Example:
|
```
|
||||||
|
{{.OriginalText}}
|
||||||
|
```
|
||||||
|
|
||||||
|
# TEMPLATE FUNCTIONS
|
||||||
|
|
||||||
|
Besides the standard functions described in go's text/template documentation,
|
||||||
|
aerc provides the following additional functions:
|
||||||
|
|
||||||
|
*wrap*
|
||||||
|
Wrap the original text to the specified number of characters per line.
|
||||||
|
|
||||||
_wrap_ function can be used to wrap the original text to a number
|
|
||||||
of characters per line.
|
|
||||||
```
|
```
|
||||||
{{wrap 72 .OriginalText}}
|
{{wrap 72 .OriginalText}}
|
||||||
```
|
```
|
||||||
|
|
||||||
_quote_ function prepends each line with "> ".
|
*quote*
|
||||||
|
Prepends each line with "> ".
|
||||||
|
|
||||||
```
|
```
|
||||||
{{quote .OriginalText}}
|
{{quote .OriginalText}}
|
||||||
```
|
```
|
||||||
|
|
||||||
_exec_ function execute external command to process message.
|
*exec*
|
||||||
|
Execute external command, provide the second argument to its stdin.
|
||||||
|
|
||||||
```
|
```
|
||||||
{{exec `/usr/local/share/aerc/filters/html`}}
|
{{exec `/usr/local/share/aerc/filters/html` .OriginalText}}
|
||||||
```
|
```
|
||||||
|
|
||||||
All of the above can be chained together if needed, for example.
|
*toLocal*
|
||||||
|
Convert the date to the local timezone as specified by the locale.
|
||||||
|
|
||||||
```
|
```
|
||||||
{{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
|
{{toLocal .Date}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Automatic HTML parsing can be achieved.
|
*dateFormat*
|
||||||
|
Format date and time according to the format passed as the second argument.
|
||||||
|
The format must be specified according to go's time package format.
|
||||||
|
|
||||||
|
```
|
||||||
|
{{dateFormat .Date "Mon Jan 2 15:04:05 -0700 MST 2006"}}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Function chaining*
|
||||||
|
All of the template functions can be chained together if needed.
|
||||||
|
|
||||||
|
Example: Automatic HTML parsing for text/html mime type messages
|
||||||
```
|
```
|
||||||
{{if eq .OriginalMIMEType "text/html"}}
|
{{if eq .OriginalMIMEType "text/html"}}
|
||||||
{{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
|
{{exec `/usr/local/share/aerc/filters/html` .OriginalText | wrap 72 | quote}}
|
||||||
|
|
Loading…
Reference in New Issue