From ec47d0b3842147a156216ed7b2630600bec73371 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Sat, 21 Dec 2019 20:44:44 +0100 Subject: allow custom date formats This adds a new datef function instead of changing date function in an effort to keep backwards compatibility. datef is intentionally used in the example to make it clear to the user that it is possible to set a custom date format. --- in.html | 2 +- openring.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/in.html b/in.html index d1437e8..a9f63e6 100644 --- a/in.html +++ b/in.html @@ -10,7 +10,7 @@ via {{.SourceTitle}} - {{.Date | date}} + {{.Date | datef "January 2, 2006"}} {{end}} diff --git a/openring.go b/openring.go index cbaba1f..4f74631 100644 --- a/openring.go +++ b/openring.go @@ -76,6 +76,9 @@ func main() { "date": func(t time.Time) string { return t.Format("January 2, 2006") }, + "datef": func(fmt string, t time.Time) string { + return t.Format(fmt) + }, }). Parse(string(input)) if err != nil { -- cgit v1.2.3