MCPcopy Create free account
hub / github.com/gogs/gogs / FuncMap

Function FuncMap

internal/template/template.go:37–135  ·  view source on GitHub ↗

FuncMap returns a list of user-defined template functions.

()

Source from the content-addressed store, hash-verified

35
36// FuncMap returns a list of user-defined template functions.
37func FuncMap() []template.FuncMap {
38 funcMapOnce.Do(func() {
39 funcMap = []template.FuncMap{map[string]any{
40 "BuildCommit": func() string {
41 return conf.BuildCommit
42 },
43 "Year": func() int {
44 return time.Now().Year()
45 },
46 "UseHTTPS": func() bool {
47 return conf.Server.URL.Scheme == "https"
48 },
49 "AppName": func() string {
50 return conf.App.BrandName
51 },
52 "AppSubURL": func() string {
53 return conf.Server.Subpath
54 },
55 "AppURL": func() string {
56 return conf.Server.ExternalURL
57 },
58 "AppVer": func() string {
59 return conf.App.Version
60 },
61 "AppDomain": func() string {
62 return conf.Server.Domain
63 },
64 "DisableGravatar": func() bool {
65 return conf.Picture.DisableGravatar
66 },
67 "ShowFooterTemplateLoadTime": func() bool {
68 return conf.Other.ShowFooterTemplateLoadTime
69 },
70 "LoadTimes": func(startTime time.Time) string {
71 return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
72 },
73 "AvatarLink": tool.AvatarLink,
74 "AppendAvatarSize": tool.AppendAvatarSize,
75 "Safe": Safe,
76 "Sanitize": bluemonday.UGCPolicy().Sanitize,
77 "Str2HTML": Str2HTML,
78 "NewLine2br": NewLine2br,
79 "TimeSince": tool.TimeSince,
80 "RawTimeSince": tool.RawTimeSince,
81 "FileSize": tool.FileSize,
82 "Subtract": tool.Subtract,
83 "Add": func(a, b int) int {
84 return a + b
85 },
86 "ActionIcon": ActionIcon,
87 "DateFmtLong": func(t time.Time) string {
88 return t.Format(time.RFC1123Z)
89 },
90 "DateFmtShort": func(t time.Time) string {
91 return t.Format("Jan 02, 2006")
92 },
93 "SubStr": func(str string, start, length int) string {
94 if str == "" {

Callers 1

newMacaronFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected