2023-01-18 15:02:59 +00:00
|
|
|
package theme
|
2023-01-17 15:18:31 +00:00
|
|
|
|
|
|
|
import (
|
2023-05-04 12:37:06 +00:00
|
|
|
"github.com/fthvgb1/wp-go/app/pkg/models"
|
|
|
|
"github.com/fthvgb1/wp-go/app/wpconfig"
|
2023-01-17 15:18:31 +00:00
|
|
|
"html/template"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-04-15 16:57:50 +00:00
|
|
|
func postsFn(fn func(models.Posts) string, a models.Posts) string {
|
|
|
|
return fn(a)
|
2023-01-17 15:18:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func FuncMap() template.FuncMap {
|
2024-01-24 07:13:29 +00:00
|
|
|
return template.FuncMap{
|
|
|
|
"unescaped": func(s string) any {
|
|
|
|
return template.HTML(s)
|
|
|
|
},
|
|
|
|
"dateCh": func(t time.Time) any {
|
|
|
|
return t.Format("2006年 01月 02日")
|
|
|
|
},
|
|
|
|
"timeFormat": func(t time.Time, format string) any {
|
|
|
|
return t.Format(format)
|
|
|
|
},
|
|
|
|
"getOption": func(k string) string {
|
|
|
|
return wpconfig.GetOption(k)
|
|
|
|
},
|
|
|
|
"getLang": wpconfig.GetLang,
|
|
|
|
"postsFn": postsFn,
|
|
|
|
"exec": func(fn func() string) template.HTML {
|
|
|
|
return template.HTML(fn())
|
|
|
|
},
|
|
|
|
"callFuncString": func(fn func(string) string, s string) template.HTML {
|
|
|
|
return template.HTML(fn(s))
|
|
|
|
},
|
2023-01-17 15:18:31 +00:00
|
|
|
}
|
|
|
|
}
|