diff options
author | Anthony Fok <foka@debian.org> | 2015-12-06 23:23:54 -0700 |
---|---|---|
committer | Anthony Fok <foka@debian.org> | 2015-12-06 23:23:54 -0700 |
commit | f13db9328b526550b9fd1d31c4c6cf80b13fc349 (patch) | |
tree | ed9ac97fefed897f691af538f6ea6a4f922d7aba /hugolib | |
parent | d35d82060fce24533fc29a04a3e341869f196172 (diff) |
Sort and remove "" from "Available templates" list
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/site.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index eeac4cfb6..e9bc1ca73 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -22,6 +22,7 @@ import ( "net/url" "os" "path/filepath" + "sort" "strconv" "strings" "sync" @@ -243,14 +244,26 @@ func (s *Site) Build() (err error) { if err = s.Process(); err != nil { return } + if err = s.Render(); err != nil { // Better reporting when the template is missing (commit 2bbecc7b) - jww.ERROR.Printf("Error rendering site: %s\nAvailable templates:\n", err) + jww.ERROR.Printf("Error rendering site: %s", err) + + jww.ERROR.Printf("Available templates:") + var keys []string for _, template := range s.Tmpl.Templates() { - jww.ERROR.Printf("\t%s\n", template.Name()) + if name := template.Name(); name != "" { + keys = append(keys, name) + } } + sort.Strings(keys) + for _, k := range keys { + jww.ERROR.Printf("\t%s\n", k) + } + return } + return nil } |