From d74400ac07a9f149e89fdf2b7232ffc6871f8553 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Mon, 6 Feb 2023 14:38:48 +0100 Subject: templates: add compactDir function This will be used in the dirtree-format replacement by templates. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- lib/templates/functions.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/templates') diff --git a/lib/templates/functions.go b/lib/templates/functions.go index 0b0a4546..1cbdc85d 100644 --- a/lib/templates/functions.go +++ b/lib/templates/functions.go @@ -246,6 +246,10 @@ func trimSignature(message string) string { return res.String() } +func compactDir(path string) string { + return format.CompactPath(path, os.PathSeparator) +} + var templateFuncs = template.FuncMap{ "quote": quote, "wrapText": wrapText, @@ -266,4 +270,5 @@ var templateFuncs = template.FuncMap{ "cwd": cwd, "join": join, "trimSignature": trimSignature, + "compactDir": compactDir, } -- cgit