hugo/tpl
Bjørn Erik Pedersen e4d6ec94b5 Allow user to handle/ignore errors in resources.Get
In Hugo 0.90.0 we introduced remote support in `resources.Get`.

But with remote resources comes with a higher chance of failing a build (network issues, remote server down etc.).

Before this commit we always failed the build on any unexpected error.

This commit allows the user to check for any error (and potentially fall back to a default local resource):

```htmlbars
{{ $result := resources.Get "https://gohugo.io/img/hugo-logo.png" }}
{{ with $result }}
        {{ if .Err }}
        {{/* log the error, insert a default image etc. *}}
        {{ else }}
        <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
        {{ end }}
{{ end }}
```

Note that the default behaviour is still to fail the build, but we will delay that error until you start using the `Resource`.

Fixes #9529
2021-12-10 11:10:41 +01:00
..
cast
collections
compare
crypto
data resources: Add timeout to the HTTP request in Get 2021-12-02 16:11:14 +01:00
debug
encoding
fmt
hugo
images
inflect
internal
js
lang Fix description of lang.FormatNumberCustom 2021-11-01 18:54:43 +01:00
math
openapi/openapi3
os
partials
path tpl/path: Add path.Clean 2021-10-05 16:15:10 +02:00
reflect
resources Allow user to handle/ignore errors in resources.Get 2021-12-10 11:10:41 +01:00
safe
site
strings
templates
time tpl/time: Use configured location when date passed to Format is string 2021-10-30 16:09:38 +02:00
tplimpl Remove empty href element from pagination template 2021-12-02 09:14:30 +01:00
transform tpl/transform: Optional options for highlight func 2021-12-07 11:26:56 +01:00
urls
template.go
template_info.go
template_test.go