From: Anthony Fok Date: Tue, 10 Mar 2015 16:18:40 +0000 (-0600) Subject: Do not parse backup files with trailing '~' as templates X-Git-Tag: v0.14~211 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3ba279c2e5cdb4cbed300c0054b68c334590b7bf;p=brevno-suite%2Fhugo Do not parse backup files with trailing '~' as templates Fixes #964 --- diff --git a/tpl/template.go b/tpl/template.go index 148ec03c..fbe4f326 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -1230,6 +1230,10 @@ func isDotFile(path string) bool { return filepath.Base(path)[0] == '.' } +func isBackupFile(path string) bool { + return path[len(path)-1] == '~' +} + func (t *GoHtmlTemplate) loadTemplates(absPath string, prefix string) { walker := func(path string, fi os.FileInfo, err error) error { if err != nil { @@ -1254,7 +1258,7 @@ func (t *GoHtmlTemplate) loadTemplates(absPath string, prefix string) { } if !fi.IsDir() { - if isDotFile(path) { + if isDotFile(path) || isBackupFile(path) { return nil }