From 35e2cee5c591d2477fc9d335d467805de6d58938 Mon Sep 17 00:00:00 2001 From: unknwon Date: Sun, 28 Jul 2019 15:10:44 -0700 Subject: [PATCH] pkg/template: use template function Year to get number of year To avoid update in each year --- pkg/template/template.go | 17 ++++++++++------- templates/base/footer.tmpl | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/template/template.go b/pkg/template/template.go index eb85ca7b0..6d6d09da8 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -33,6 +33,9 @@ func NewFuncMap() []template.FuncMap { "GoVer": func() string { return strings.Title(runtime.Version()) }, + "Year": func() int { + return time.Now().Year() + }, "UseHTTPS": func() bool { return strings.HasPrefix(setting.AppURL, "https") }, @@ -94,13 +97,13 @@ func NewFuncMap() []template.FuncMap { } return str[start:end] }, - "Join": strings.Join, - "EllipsisString": tool.EllipsisString, - "DiffTypeToStr": DiffTypeToStr, - "DiffLineTypeToStr": DiffLineTypeToStr, - "Sha1": Sha1, - "ShortSHA1": tool.ShortSHA1, - "MD5": tool.MD5, + "Join": strings.Join, + "EllipsisString": tool.EllipsisString, + "DiffTypeToStr": DiffTypeToStr, + "DiffLineTypeToStr": DiffLineTypeToStr, + "Sha1": Sha1, + "ShortSHA1": tool.ShortSHA1, + "MD5": tool.MD5, "ActionContent2Commits": ActionContent2Commits, "EscapePound": EscapePound, "RenderCommitMessage": RenderCommitMessage, diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 666d826cc..562009d1d 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -7,7 +7,7 @@