aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-06-08 22:16:31 +0200
committerRobin Jarry <robin@jarry.cc>2023-06-10 23:54:06 +0200
commit9479513ec138b0e4b2ad2c53a0566c00c7035845 (patch)
tree98ce844e82eeebf2151a3c0fa1ac1b530964f344 /doc
parent8162c5be8f251e985a18928ed1a8cb571df40945 (diff)
downloadaerc-9479513ec138b0e4b2ad2c53a0566c00c7035845.tar.gz
templates: add map functions
Similar to switch and .StyleSwitch, add map and .StyleMap to work on lists. An extra "exclude" item is available to filter elements out of the list. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'doc')
-rw-r--r--doc/aerc-templates.7.scd19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd
index 6919e5dd..394e22b6 100644
--- a/doc/aerc-templates.7.scd
+++ b/doc/aerc-templates.7.scd
@@ -402,6 +402,16 @@ aerc provides the following additional functions:
{{.StyleSwitch (.From | names | join ", ") (case `Tim` "cyan") (case `Robin` "pink-blink") (default "blue")}}
```
+*.StyleMap*
+ Apply user-defined styles (see *aerc-stylesets*(7)) to elements of
+ a string list. The logic is the same than *.StyleSwitch* but works on
+ a list of elements. An additional *exclude* option is available to
+ remove the matching elements from the list.
+
+ ```
+ {{.StyleMap .Labels (exclude .Folder) (exclude `^spam$`) (case `^inbox$` "red") (case `^Archive/.*` "green") (default "blue") | join " "}}
+ ```
+
*version*
Returns the version of aerc, which can be useful for things like X-Mailer.
@@ -426,6 +436,15 @@ aerc provides the following additional functions:
{{switch .Folder (case `^INBOX$` "📥") (case `^Archive/.*` "🗃") (default "📁")}}
```
+*map*
+ Transform a string list into another one. The logic is the same than
+ *switch* but works on a list of elements. An additional *exclude* option
+ is available to remove the matching elements from the list.
+
+ ```
+ {{map .Labels (exclude .Folder) (exclude `^spam$`) (case `^inbox$` "📥") (case `^Archive/.*` "🗃") | join " "}}
+ ```
+
*Function chaining*
All of the template functions can be chained together if needed.