hugo/tpl
Bjørn Erik Pedersen 02eaddc2fb
tpl/tplimpl: Fix template truth logic
Before this commit, due to a bug in Go's `text/template` package, this would print different output for typed nil interface values:

```
{{ if .AuthenticatedUser }}User is authenticated!{{ else }}{{ end }}
{{ if not .AuthenticatedUser }}{{ else }}}User is authenticated!{{ end }}
```

This commit works around this by wrapping every `if` and `with` with a custom `getif` template func with truth logic that matches `not`, `and` and `or`.

Those 3 template funcs from Go's stdlib are now pulled into Hugo's source tree and adjusted to support custom zero values, e.g. types that implement `IsZero`.

This means that you can now do:

```
{{ with .Date }}{{ . }}{{ end }}
```

And it would work as expected.

Fixes #5738
2019-03-06 22:52:38 +01:00
..
cast Make docshelper run again 2018-12-27 10:08:44 +01:00
collections Support nested keys/fields with missing values with the where function 2019-02-06 19:53:34 +01:00
compare tpl/tplimpl: Fix template truth logic 2019-03-06 22:52:38 +01:00
crypto tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
data tpl/data: Adjust tests 2019-02-01 08:54:30 +01:00
encoding tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
fmt tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
hugo tpl/hugo: Use the correct Hugo var 2018-12-06 14:57:56 +01:00
images tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
inflect tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
internal tpl: Fix test to pass with gccgo 2018-11-09 08:54:08 +01:00
lang tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
math tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
os tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
partials tpl: Fix strings.HasPrefix args order 2019-02-02 01:26:05 +01:00
path tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
reflect tpl: Add reflect namespace 2018-12-07 23:29:37 +01:00
resources resources: Move resource interfaces into its own package 2019-01-02 14:25:37 +01:00
safe tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
site Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00
strings tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
templates tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
time tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
tplimpl tpl/tplimpl: Fix template truth logic 2019-03-06 22:52:38 +01:00
transform resources: Move resource interfaces into its own package 2019-01-02 14:25:37 +01:00
urls tpl: Add godoc packages comments 2018-11-30 08:56:30 +01:00
template.go Add file (line/col) info to ref/relref errors 2018-11-01 21:06:35 +01:00
template_test.go commands: Show server error info in browser 2018-10-16 22:10:56 +02:00