From 9d8d74d9bf438c337ac0d6eed1b5dede5cc0ceb2 Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Wed, 10 Jul 2024 22:26:22 +0200 Subject: templates: add head and tail functions Add head and tail functions to get beginning or ends of strings. E.g.: {{"hello" | head 2}} will return "he" {{"hello" | tail 2}} will return "lo" Implements: https://todo.sr.ht/~rjarry/aerc/220 Changelog-added: New `head` and `tail` templates functions for strings. Signed-off-by: Bence Ferdinandy Reviewed-by: Moritz Poldrack Acked-by: Robin Jarry --- doc/aerc-templates.7.scd | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc') diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd index b5681030..2c773bef 100644 --- a/doc/aerc-templates.7.scd +++ b/doc/aerc-templates.7.scd @@ -490,6 +490,20 @@ aerc provides the following additional functions: {{replace `(.+) - .+ at .+\..+` `$1` ((index .OriginalFrom 0).Name)}} ``` +*head* + Return first n characters from string. + + ``` + {{"hello" | head 2}} + ``` + +*tail* + Return last n characters from string. + + ``` + {{"hello" | tail 2}} + ``` + *.Style* Apply a user-defined style (see *aerc-stylesets*(7)) to a string. -- cgit