diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 10:25:29 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 492327368848bcf21cfd23d5490bc47b6ea44897 (patch) | |
tree | 8b43c7f6de73deae99bec9beb4e1d94ba7f8d0c6 /tpl | |
parent | 930a3df1b79d21f005a63918b89cc01ae5a4cd9e (diff) |
tplimpl: Fix lookup with non-standard layout folder
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/tplimpl/template.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go index 545d5994a..ea12cde7a 100644 --- a/tpl/tplimpl/template.go +++ b/tpl/tplimpl/template.go @@ -476,25 +476,23 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) { return nil } - workingDir := t.PathSpec.WorkingDir() - themeDir := t.PathSpec.GetThemeDir() + var ( + workingDir = t.PathSpec.WorkingDir() + themeDir = t.PathSpec.GetThemeDir() + layoutDir = t.PathSpec.LayoutDir() + ) if themeDir != "" && strings.HasPrefix(absPath, themeDir) { workingDir = themeDir + layoutDir = "layouts" } - li := strings.LastIndex(path, t.PathSpec.LayoutDir()) + len(t.PathSpec.LayoutDir()) + 1 - - if li < 0 { - // Possibly a theme - li = strings.LastIndex(path, "layouts") + 8 - } - + li := strings.LastIndex(path, layoutDir) + len(layoutDir) + 1 relPath := path[li:] descriptor := output.TemplateLookupDescriptor{ WorkingDir: workingDir, - LayoutDir: t.PathSpec.LayoutDir(), + LayoutDir: layoutDir, RelPath: relPath, Prefix: prefix, Theme: t.PathSpec.Theme(), @@ -509,6 +507,7 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) { tplID, err := output.CreateTemplateNames(descriptor) if err != nil { t.Log.ERROR.Printf("Failed to resolve template in path %q: %s", path, err) + return nil } |