forked from goffee/core
theme base system
This commit is contained in:
parent
1172e23c16
commit
465e88bf40
7 changed files with 74 additions and 51 deletions
36
templates.go
Normal file
36
templates.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
|
||||
// Use of this source code is governed by MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var tmpl *template.Template = nil
|
||||
|
||||
func NewTemplates(components embed.FS, templates embed.FS) {
|
||||
// templates
|
||||
var paths []string
|
||||
fs.WalkDir(components, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if strings.Contains(d.Name(), ".html") {
|
||||
paths = append(paths, path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
var pathst []string
|
||||
fs.WalkDir(templates, ".", func(patht string, d fs.DirEntry, err error) error {
|
||||
if strings.Contains(d.Name(), ".html") {
|
||||
pathst = append(pathst, patht)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
tmpla := template.Must(template.ParseFS(components, paths...))
|
||||
tmpl = template.Must(tmpla.ParseFS(templates, pathst...))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue