aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/base/template.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/template.go')
-rw-r--r--plugins/base/template.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/base/template.go b/plugins/base/template.go
new file mode 100644
index 0000000..84c4e21
--- /dev/null
+++ b/plugins/base/template.go
@@ -0,0 +1,29 @@
+package koushinbase
+
+import (
+ "html/template"
+ "net/url"
+ "strings"
+ "time"
+
+ "github.com/emersion/go-imap"
+)
+
+var templateFuncs = template.FuncMap{
+ "tuple": func(values ...interface{}) []interface{} {
+ return values
+ },
+ "pathescape": func(s string) string {
+ return url.PathEscape(s)
+ },
+ "formataddrlist": func(addrs []*imap.Address) string {
+ l := make([]string, len(addrs))
+ for i, addr := range addrs {
+ l[i] = addr.PersonalName + " <" + addr.Address() + ">"
+ }
+ return strings.Join(l, ", ")
+ },
+ "formatdate": func(t time.Time) string {
+ return t.Format("Mon Jan 02 15:04")
+ },
+}