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 Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
collections Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
compare Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
crypto Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
data resources: Add timeout to the HTTP request in Get 2021-12-02 16:11:14 +01:00
debug Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
encoding Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
fmt Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
hugo Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
images Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
inflect Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
internal Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
js Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
lang Fix description of lang.FormatNumberCustom 2021-11-01 18:54:43 +01:00
math Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
openapi/openapi3 Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
os Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
partials Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
path tpl/path: Add path.Clean 2021-10-05 16:15:10 +02:00
reflect Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
resources Allow user to handle/ignore errors in resources.Get 2021-12-10 11:10:41 +01:00
safe Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
site Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
strings Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
templates Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
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 Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
template.go all: Fix minor typos 2020-12-16 12:11:32 +01:00
template_info.go Add render template hooks for links and images 2019-12-18 11:44:40 +01:00
template_test.go Create lightweight forks of text/template and html/template 2019-12-12 09:59:34 +01:00