Skip to content
Permalink
Browse files

resources: Return nil when not found in resources.Get

Fixes #5999
  • Loading branch information...
bep committed May 29, 2019
1 parent d44d3ea commit 4c560020bc0c50f8004873be8adf83698b7c095a
Showing with 8 additions and 0 deletions.
  1. +5 −0 hugolib/resource_chain_test.go
  2. +3 −0 resources/resource.go
@@ -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) {
}},
@@ -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

0 comments on commit 4c56002

Please sign in to comment.
You can’t perform that action at this time.