Allow partial without .html
authorAustin Ziegler <austin@zieglers.ca>
Sat, 1 Nov 2014 04:15:22 +0000 (00:15 -0400)
committerspf13 <steve.francia@gmail.com>
Thu, 13 Nov 2014 17:30:45 +0000 (12:30 -0500)
`partial "header" .` means the same thing as `partial "header.html" .`.

hugolib/template.go

index 20c57701d9d7d9434e0cc68145fde6d5e859bd6d..2de1396f7c297dfaab61a2b0592d0333acce7aaa 100644 (file)
@@ -563,10 +563,16 @@ func ExecuteTemplate(context interface{}, layouts ...string) *bytes.Buffer {
        buffer := new(bytes.Buffer)
        worked := false
        for _, layout := range layouts {
-               if localTemplates.Lookup(layout) != nil {
-                       err := localTemplates.ExecuteTemplate(buffer, layout, context)
+               name := layout
+
+               if localTemplates.Lookup(name) == nil {
+                       name = layout + ".html"
+               }
+
+               if localTemplates.Lookup(name) != nil {
+                       err := localTemplates.ExecuteTemplate(buffer, name, context)
                        if err != nil {
-                               jww.ERROR.Println(err, "in", layout)
+                               jww.ERROR.Println(err, "in", name)
                        }
                        worked = true
                        break