aboutsummaryrefslogtreecommitdiffhomepage
path: root/template/functions.go
diff options
context:
space:
mode:
authorGravatar Dave Z <dzaikos@users.noreply.github.com>2018-07-17 21:48:28 -0400
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-07-17 18:48:28 -0700
commit3b018bc6bf3b182b0ed24ee2956d0d7ef31ebb07 (patch)
treeccff9b2560177c2094a666d1ac93bb3dcec09d95 /template/functions.go
parent6aa02680d80709d714672dd842dc3dc2533339fe (diff)
Show feed title instead of domain in items list
Diffstat (limited to 'template/functions.go')
-rw-r--r--template/functions.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/template/functions.go b/template/functions.go
index f68d6fb..4673487 100644
--- a/template/functions.go
+++ b/template/functions.go
@@ -5,6 +5,7 @@
package template
import (
+ "bytes"
"html/template"
"net/mail"
"strings"
@@ -77,6 +78,18 @@ func (f *funcMap) Map() template.FuncMap {
return ts.Format("2006-01-02 15:04:05")
},
"dict": dict,
+ "truncate": func(str string, max int) string {
+ if len(str) > max {
+ var buffer bytes.Buffer
+
+ buffer.WriteString(str[:max-1])
+ buffer.WriteString("…")
+
+ return buffer.String()
+ }
+
+ return str
+ },
// These functions are overrided at runtime after the parsing.
"elapsed": func(timezone string, t time.Time) string {