summaryrefslogtreecommitdiff
path: root/internal/template/functions.go
diff options
context:
space:
mode:
authorGravatar jvoisin <julien.voisin@dustri.org> 2024-02-27 20:39:39 +0100
committerGravatar Frédéric Guillot <f@miniflux.net> 2024-02-28 19:32:38 -0800
commit6b3b8e8c9b9a73338be1d4137289f6653d9de595 (patch)
treecded1e20ba81235e1124a22a0f2e9c361437aa56 /internal/template/functions.go
parent5a7d6f89975959e0a1a63f1ac68d5bb41f01ab2c (diff)
downloadv2-6b3b8e8c9b9a73338be1d4137289f6653d9de595.tar.gz
v2-6b3b8e8c9b9a73338be1d4137289f6653d9de595.tar.zst
v2-6b3b8e8c9b9a73338be1d4137289f6653d9de595.zip
Inline some templating functions
Diffstat (limited to 'internal/template/functions.go')
-rw-r--r--internal/template/functions.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/internal/template/functions.go b/internal/template/functions.go
index 08720dff..e050ffaa 100644
--- a/internal/template/functions.go
+++ b/internal/template/functions.go
@@ -36,12 +36,8 @@ func (f *funcMap) Map() template.FuncMap {
"hasKey": hasKey,
"truncate": truncate,
"isEmail": isEmail,
- "baseURL": func() string {
- return config.Opts.BaseURL()
- },
- "rootURL": func() string {
- return config.Opts.RootURL()
- },
+ "baseURL": config.Opts.BaseURL,
+ "rootURL": config.Opts.RootURL,
"hasOAuth2Provider": func(provider string) bool {
return config.Opts.OAuth2Provider() == provider
},
@@ -75,24 +71,16 @@ func (f *funcMap) Map() template.FuncMap {
"mustBeProxyfied": func(mediaType string) bool {
return slices.Contains(config.Opts.ProxyMediaTypes(), mediaType)
},
- "domain": func(websiteURL string) string {
- return urllib.Domain(websiteURL)
- },
- "hasPrefix": func(str, prefix string) bool {
- return strings.HasPrefix(str, prefix)
- },
- "contains": func(str, substr string) bool {
- return strings.Contains(str, substr)
- },
+ "domain": urllib.Domain,
+ "hasPrefix": strings.HasPrefix,
+ "contains": strings.Contains,
"replace": func(str, old, new string) string {
return strings.Replace(str, old, new, 1)
},
"isodate": func(ts time.Time) string {
return ts.Format("2006-01-02 15:04:05")
},
- "theme_color": func(theme, colorScheme string) string {
- return model.ThemeColor(theme, colorScheme)
- },
+ "theme_color": model.ThemeColor,
"icon": func(iconName string) template.HTML {
return template.HTML(fmt.Sprintf(
`<svg class="icon" aria-hidden="true"><use xlink:href="%s#icon-%s"/></svg>`,