diff --git a/app/theme/fs.go b/app/theme/fs.go index 2e7efb4..6056c72 100644 --- a/app/theme/fs.go +++ b/app/theme/fs.go @@ -26,7 +26,6 @@ func BuildTemplate() *multipTemplate.MultipleFsTemplate { } } else { multiple = multipTemplate.NewFsTemplates(TemplateFs, templates) - multiple.FuncMap = FuncMap() commonTemplate(multiple) } @@ -53,10 +52,11 @@ func commonTemplate(t *multipTemplate.MultipleFsTemplate) { if err != nil { panic(err) } + funMap := FuncMap() for _, main := range m { file := filepath.Base(main) dir := strings.Split(main, "/")[0] - templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "wp/template.gohtml")) + templ := template.Must(template.New(file).Funcs(funMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "wp/template.gohtml")) t.SetTemplate(main, templ) } } diff --git a/multipTemplate/multiptemplate.go b/multipTemplate/multiptemplate.go index bc98261..4aa3470 100644 --- a/multipTemplate/multiptemplate.go +++ b/multipTemplate/multiptemplate.go @@ -10,7 +10,6 @@ import ( type MultipleFileTemplate struct { Template maps - FuncMap template.FuncMap } type MultipleFsTemplate struct { MultipleFileTemplate @@ -52,14 +51,12 @@ func (t *MultipleFsTemplate) AppendTemplate(name string, templates ...string) *M func NewFileTemplates(m maps) *MultipleFileTemplate { return &MultipleFileTemplate{ Template: m, - FuncMap: make(template.FuncMap), } } func NewFsTemplate(f embed.FS) *MultipleFsTemplate { return &MultipleFsTemplate{ MultipleFileTemplate: MultipleFileTemplate{ Template: TemplateMaps(make(map[string]*template.Template)), - FuncMap: make(template.FuncMap), }, Fs: f, } @@ -68,7 +65,6 @@ func NewFsTemplates(f embed.FS, m maps) *MultipleFsTemplate { return &MultipleFsTemplate{ MultipleFileTemplate: MultipleFileTemplate{ Template: m, - FuncMap: make(template.FuncMap), }, Fs: f, }