Skip to content

Commit

Permalink
resources: Return nil when not found in resources.Get
Browse files Browse the repository at this point in the history
Fixes #5999
  • Loading branch information
bep committed May 29, 2019
1 parent d44d3ea commit 4c56002
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hugolib/resource_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ CSV2: {{ $csv2 }}
`CSV2: [[a b c]]`,
)
}},
{"resources.Get", func() bool { return true }, func(b *sitesBuilder) {
b.WithTemplates("home.html", `NOT FOUND: {{ if (resources.Get "this-does-not-exist") }}FAILED{{ else }}OK{{ end }}`)
}, func(b *sitesBuilder) {
b.AssertFileContent("public/index.html", "NOT FOUND: OK")
}},

{"template", func() bool { return true }, func(b *sitesBuilder) {}, func(b *sitesBuilder) {
}},
Expand Down
3 changes: 3 additions & 0 deletions resources/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func (r *Spec) newResource(sourceFs afero.Fs, fd ResourceSourceDescriptor) (reso
var err error
fi, err = sourceFs.Stat(fd.SourceFilename)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
sourceFilename = fd.SourceFilename
Expand Down

0 comments on commit 4c56002

Please sign in to comment.