URI: 
       Expand the ACE base template lookup pattern - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit beff6805340203434d2b8ca738194b781fd37b83
   DIR parent be46a4b9b03df85f786866da7a3a657f978a26bd
  HTML Author: bep <bjorn.erik.pedersen@gmail.com>
       Date:   Sat, 18 Apr 2015 13:58:35 +0200
       
       Expand the ACE base template lookup pattern
       
       The previous implementation didn't easily support the use case "I want one base template for the single pages, another for the rest".
       
       The new lookup order is:
       
       1. <current-path>/<template-name>-baseof.ace, e.g. list-baseof.ace
       2. <current-path>/baseof.ace
       3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
       4. _default/baseof.ace
       
       Diffstat:
         M tpl/template.go                     |      29 +++++++++++++++++++++--------
       
       1 file changed, 21 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/tpl/template.go b/tpl/template.go
       @@ -15,6 +15,7 @@ package tpl
        
        import (
                "bytes"
       +        "fmt"
                "github.com/eknkc/amber"
                bp "github.com/spf13/hugo/bufferpool"
                "github.com/spf13/hugo/helpers"
       @@ -279,14 +280,26 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) {
                                                return err
                                        }
                                        if needsBase {
       -                                        // Look for the base first in the current path, then in _default.
       -                                        p := filepath.Join(filepath.Dir(path), baseAceFilename)
       -                                        if ok, err := helpers.Exists(p, hugofs.OsFs); err == nil && ok {
       -                                                baseTemplatePath = p
       -                                        } else {
       -                                                p := filepath.Join(absPath, "_default", baseAceFilename)
       -                                                if ok, err := helpers.Exists(p, hugofs.OsFs); err == nil && ok {
       -                                                        baseTemplatePath = p
       +
       +                                        // Look for base template in the follwing order:
       +                                        //   1. <current-path>/<template-name>-baseof.ace, e.g. list-baseof.ace.
       +                                        //   2. <current-path>/baseof.ace
       +                                        //   3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
       +                                        //   4. _default/baseof.ace
       +
       +                                        currBaseAceFilename := fmt.Sprintf("%s-%s", helpers.Filename(path), baseAceFilename)
       +                                        templateDir := filepath.Dir(path)
       +
       +                                        pathsToCheck := []string{
       +                                                filepath.Join(templateDir, currBaseAceFilename),
       +                                                filepath.Join(templateDir, baseAceFilename),
       +                                                filepath.Join(absPath, "_default", currBaseAceFilename),
       +                                                filepath.Join(absPath, "_default", baseAceFilename)}
       +
       +                                        for _, pathToCheck := range pathsToCheck {
       +                                                if ok, err := helpers.Exists(pathToCheck, hugofs.OsFs); err == nil && ok {
       +                                                        baseTemplatePath = pathToCheck
       +                                                        break
                                                        }
                                                }
                                        }