mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
templates.go: Support default base templates
If a base template is not found in the current directory, look for a default base template at templates/_default/base.ext. Also prevent partial templates from inheriting from base templates.
This commit is contained in:
parent
0a2e7b6fd0
commit
63b63a32e1
10
templates.go
10
templates.go
|
@ -148,11 +148,19 @@ func (t *Templates) Load(dir string, exts []string) error {
|
|||
if _, ok := extsMap[ext]; !ok {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(path, "_partials/") {
|
||||
continue
|
||||
}
|
||||
basePath := pathpkg.Join(pathpkg.Dir(path), "base"+ext)
|
||||
if path == basePath {
|
||||
continue
|
||||
}
|
||||
if base, ok := t.tmpls[basePath]; ok {
|
||||
base, ok := t.tmpls[basePath]
|
||||
if !ok {
|
||||
basePath = pathpkg.Join("_default", "base"+ext)
|
||||
base, ok = t.tmpls[basePath]
|
||||
}
|
||||
if ok {
|
||||
tmpl, err := base.Clone()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue