hugo/tpl/tplimpl
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
..
embedded Fix OpenGraph image fallback to site params 2019-01-25 18:14:10 +01:00
ace.go Fix broken shortcodes for Ace and Amber 2017-11-18 10:41:31 +01:00
amber_compiler.go tpl/tplimpl: Fix compiling Amber templates that import other templates 2018-08-17 10:04:07 +02:00
template.go Fix some inline shortcode issues 2019-01-31 19:08:19 +01:00
template_ast_transformers.go tpl/tplimpl: Fix template truth logic 2019-03-06 22:52:38 +01:00
template_ast_transformers_test.go tpl/tplimpl: Fix template truth logic 2019-03-06 22:52:38 +01:00
template_errors.go hugolib: Continue the file context/line number errors work 2018-10-22 20:46:14 +02:00
template_funcs.go tpl: Fix reflect 2018-12-28 10:41:46 +01:00
template_funcs_test.go Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00
template_test.go Add Hugo Piper with SCSS support and much more 2018-07-06 11:46:12 +02:00
templateFuncster.go tpl: Fix strings.HasPrefix args order 2019-02-02 01:26:05 +01:00
templateProvider.go commands: Show server error info in browser 2018-10-16 22:10:56 +02:00