fixed #303. Adding theme support to views

This commit is contained in:
spf13
2014-06-03 17:06:32 -04:00
parent e0ea6b9955
commit 640ab3c72e
3 changed files with 46 additions and 28 deletions

View File

@@ -190,11 +190,21 @@ func (page *Page) Layout(l ...string) []string {
func layouts(types string, layout string) (layouts []string) {
t := strings.Split(types, "/")
// Add type/layout.html
for i := range t {
search := t[:len(t)-i]
layouts = append(layouts, fmt.Sprintf("%s/%s.html", strings.ToLower(path.Join(search...)), layout))
}
layouts = append(layouts, fmt.Sprintf("%s.html", layout))
// Add _default/layout.html
layouts = append(layouts, fmt.Sprintf("_default/%s.html", layout))
// Add theme/type/layout.html & theme/_default/layout.html
for _, l := range layouts {
layouts = append(layouts, "theme/"+l)
}
return
}