Print layout name if it was specified when showing missing layout file error

Fixes #7617
This commit is contained in:
Andreas Richter 2020-09-13 14:36:37 -04:00 committed by GitHub
parent 4fad43c8bd
commit 9df60b62f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -1721,7 +1721,7 @@ func (hr hookRenderer) RenderHeading(w io.Writer, ctx hooks.HeadingContext) erro
func (s *Site) renderForTemplate(name, outputFormat string, d interface{}, w io.Writer, templ tpl.Template) (err error) { func (s *Site) renderForTemplate(name, outputFormat string, d interface{}, w io.Writer, templ tpl.Template) (err error) {
if templ == nil { if templ == nil {
s.logMissingLayout(name, "", outputFormat) s.logMissingLayout(name, "", "", outputFormat)
return nil return nil
} }

View file

@ -130,7 +130,7 @@ func pageRenderer(
} }
if !found { if !found {
s.logMissingLayout("", p.Kind(), p.f.Name) s.logMissingLayout("", p.Layout(), p.Kind(), p.f.Name)
continue continue
} }
@ -148,7 +148,7 @@ func pageRenderer(
} }
} }
func (s *Site) logMissingLayout(name, kind, outputFormat string) { func (s *Site) logMissingLayout(name, layout, kind, outputFormat string) {
log := s.Log.WARN log := s.Log.WARN
if name != "" && infoOnMissingLayout[name] { if name != "" && infoOnMissingLayout[name] {
log = s.Log.INFO log = s.Log.INFO
@ -162,6 +162,11 @@ func (s *Site) logMissingLayout(name, kind, outputFormat string) {
args = append(args, outputFormat) args = append(args, outputFormat)
} }
if layout != "" {
msg += " for layout %q"
args = append(args, layout)
}
if kind != "" { if kind != "" {
msg += " for kind %q" msg += " for kind %q"
args = append(args, kind) args = append(args, kind)