aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/template.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/base/template.go b/plugins/base/template.go
index 482674a..7d85db6 100644
--- a/plugins/base/template.go
+++ b/plugins/base/template.go
@@ -3,11 +3,17 @@ package alpsbase
import (
"html/template"
"net/url"
+ "strings"
"time"
"github.com/emersion/go-imap"
)
+const (
+ inputDateLayout = "2006-01-02"
+ inputTimeLayout = "15:04"
+)
+
var templateFuncs = template.FuncMap{
"tuple": func(values ...interface{}) []interface{} {
return values
@@ -40,4 +46,19 @@ var templateFuncs = template.FuncMap{
return true
}
},
+ "join": func(l []string, sep string) string {
+ return strings.Join(l, sep)
+ },
+ "formatinputdate": func(t time.Time) string {
+ if t.IsZero() {
+ return ""
+ }
+ return t.Format(inputDateLayout)
+ },
+ "formatinputtime": func(t time.Time) string {
+ if t.IsZero() {
+ return ""
+ }
+ return t.Format(inputTimeLayout)
+ },
}