diff --git a/templates.go b/templates.go index aceea75..faf4379 100644 --- a/templates.go +++ b/templates.go @@ -49,23 +49,19 @@ func initTemplate(name string) { log.Info(" %s%s%s.tmpl", templatesDir, string(filepath.Separator), name) } + files := []string{ + filepath.Join(templatesDir, name+".tmpl"), + filepath.Join(templatesDir, "include", "footer.tmpl"), + filepath.Join(templatesDir, "base.tmpl"), + } if name == "collection" || name == "collection-tags" { // These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl" - templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles( - filepath.Join(templatesDir, name+".tmpl"), - filepath.Join(templatesDir, "include", "posts.tmpl"), - filepath.Join(templatesDir, "include", "footer.tmpl"), - filepath.Join(templatesDir, "include", "render.tmpl"), - filepath.Join(templatesDir, "base.tmpl"), - )) - } else { - templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles( - filepath.Join(templatesDir, name+".tmpl"), - filepath.Join(templatesDir, "include", "footer.tmpl"), - filepath.Join(templatesDir, "include", "render.tmpl"), - filepath.Join(templatesDir, "base.tmpl"), - )) + files = append(files, filepath.Join(templatesDir, "include", "posts.tmpl")) + } + if name == "collection" || name == "collection-tags" || name == "collection-post" || name == "post" { + files = append(files, filepath.Join(templatesDir, "include", "render.tmpl")) } + templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles(files...)) } func initPage(path, key string) { @@ -76,7 +72,6 @@ func initPage(path, key string) { pages[key] = template.Must(template.New("").Funcs(funcMap).ParseFiles( path, filepath.Join(templatesDir, "include", "footer.tmpl"), - filepath.Join(templatesDir, "include", "render.tmpl"), filepath.Join(templatesDir, "base.tmpl"), )) } @@ -90,7 +85,6 @@ func initUserPage(path, key string) { path, filepath.Join(templatesDir, "user", "include", "header.tmpl"), filepath.Join(templatesDir, "user", "include", "footer.tmpl"), - filepath.Join(templatesDir, "include", "render.tmpl"), )) }