mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Add support for baseof.ace templates in themes.
When we find a template that requires a base template, we should also look for that base template in the current theme. Fixes #1215.
This commit is contained in:
parent
29e786aac5
commit
0987e98db3
2 changed files with 11 additions and 1 deletions
|
@ -35,6 +35,8 @@ In Hugo the base template will be chosen in the following order:
|
||||||
2. <current-path>/baseof.ace
|
2. <current-path>/baseof.ace
|
||||||
3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
||||||
4. _default/baseof.ace
|
4. _default/baseof.ace
|
||||||
|
5. <themedir>/layouts/_default/<template-name>-baseof.ace
|
||||||
|
6. <themedir>/layouts/_default/baseof.ace
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above, `current-path` is where the corresponding inner template lives, `list.ace`, `single.ace`, `index.ace` ...
|
In the above, `current-path` is where the corresponding inner template lives, `list.ace`, `single.ace`, `index.ace` ...
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
"github.com/spf13/hugo/hugofs"
|
"github.com/spf13/hugo/hugofs"
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"github.com/yosssi/ace"
|
"github.com/yosssi/ace"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
@ -300,15 +301,22 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) {
|
||||||
// 2. <current-path>/baseof.ace
|
// 2. <current-path>/baseof.ace
|
||||||
// 3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
// 3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
||||||
// 4. _default/baseof.ace
|
// 4. _default/baseof.ace
|
||||||
|
// 5. <themedir>/layouts/_default/<template-name>-baseof.ace
|
||||||
|
// 6. <themedir>/layouts/_default/baseof.ace
|
||||||
|
|
||||||
currBaseAceFilename := fmt.Sprintf("%s-%s", helpers.Filename(path), baseAceFilename)
|
currBaseAceFilename := fmt.Sprintf("%s-%s", helpers.Filename(path), baseAceFilename)
|
||||||
templateDir := filepath.Dir(path)
|
templateDir := filepath.Dir(path)
|
||||||
|
themeDir := filepath.Join(
|
||||||
|
viper.GetString("WorkingDir"), "themes", viper.GetString("theme"))
|
||||||
|
|
||||||
pathsToCheck := []string{
|
pathsToCheck := []string{
|
||||||
filepath.Join(templateDir, currBaseAceFilename),
|
filepath.Join(templateDir, currBaseAceFilename),
|
||||||
filepath.Join(templateDir, baseAceFilename),
|
filepath.Join(templateDir, baseAceFilename),
|
||||||
filepath.Join(absPath, "_default", currBaseAceFilename),
|
filepath.Join(absPath, "_default", currBaseAceFilename),
|
||||||
filepath.Join(absPath, "_default", baseAceFilename)}
|
filepath.Join(absPath, "_default", baseAceFilename),
|
||||||
|
filepath.Join(themeDir, "layouts", "_default", currBaseAceFilename),
|
||||||
|
filepath.Join(themeDir, "layouts", "_default", baseAceFilename),
|
||||||
|
}
|
||||||
|
|
||||||
for _, pathToCheck := range pathsToCheck {
|
for _, pathToCheck := range pathsToCheck {
|
||||||
if ok, err := helpers.Exists(pathToCheck, hugofs.OsFs); err == nil && ok {
|
if ok, err := helpers.Exists(pathToCheck, hugofs.OsFs); err == nil && ok {
|
||||||
|
|
Loading…
Reference in a new issue