From 41ae3639051869921b62c1bda51b88b6b71faec5 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 4 Mar 2023 01:15:16 +0100 Subject: templates: add conditional style method Add .StyleSwitch that takes a string and an arbitrary number of cases (regexp, style). Reuse some of the constructs introduced by previous commit. The style of the first regular expression that matches will be applied. If the string does not match any of the expressions, it will be left as-is. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- doc/aerc-templates.7.scd | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'doc') diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd index 7f3d6410..05084216 100644 --- a/doc/aerc-templates.7.scd +++ b/doc/aerc-templates.7.scd @@ -377,6 +377,15 @@ aerc provides the following additional functions: {{.Style .Account "red"}} ``` +*.StyleSwitch* + Apply a user-defined style (see *aerc-stylesets*(7)) to a string if it + matches one of the associated regular expressions. If the string does + not match any of the expressions, leave it unstyled. + + ``` + {{.StyleSwitch (.From | names | join ", ") (case `Tim` "cyan") (case `Robin` "pink-blink")}} + ``` + *version* Returns the version of aerc, which can be useful for things like X-Mailer. -- cgit