resources: Return nil when not found in resources.Get

Fixes #5999
This commit is contained in:
Bjørn Erik Pedersen 2019-05-29 22:33:03 +02:00
parent d44d3ea898
commit 4c560020bc
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 8 additions and 0 deletions

View file

@ -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) {
}},

View file

@ -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