mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 07:18:54 +00:00
hugolib: Return error from .Render when template not found
Closes #15052
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
d15baf53a9
commit
fe06735214
@@ -114,7 +114,7 @@ func (pco *pageContentOutput) Render(ctx context.Context, layout ...string) (tem
|
||||
}
|
||||
|
||||
if !found {
|
||||
return "", nil
|
||||
return "", fmt.Errorf("template %q not found", layout[0])
|
||||
}
|
||||
|
||||
// Make sure to send the *pageState and not the *pageContentOutput to the template.
|
||||
|
||||
@@ -2055,3 +2055,21 @@ disableKinds = ["taxonomy", "term"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See issue 15052.
|
||||
func TestRenderViewNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
|
||||
-- layouts/home.html --
|
||||
{{ .Render "view_foo" }}
|
||||
{{ .Render "view_bar" }}
|
||||
-- layouts/view_foo.html --
|
||||
foo
|
||||
`
|
||||
|
||||
b, err := TestE(t, files)
|
||||
b.Assert(err, qt.ErrorMatches, `.*template "view_bar" not found.*`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user