tpl: Get rid of the custom template truth logic

Fixes #6615
This commit is contained in:
Bjørn Erik Pedersen
2019-12-18 16:50:34 +01:00
parent 3e316155c5
commit d20ca37005
9 changed files with 39 additions and 258 deletions

View File

@@ -307,7 +307,7 @@ func IsTrue(val interface{}) (truth, ok bool) {
return isTrue(reflect.ValueOf(val))
}
func isTrue(val reflect.Value) (truth, ok bool) {
func isTrueOld(val reflect.Value) (truth, ok bool) {
if !val.IsValid() {
// Something like var x interface{}, never set. It's a form of nil.
return false, true

View File

@@ -17,6 +17,8 @@ import (
"io"
"reflect"
"github.com/gohugoio/hugo/common/hreflect"
"github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse"
)
@@ -301,3 +303,7 @@ func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, a
}
return v
}
func isTrue(val reflect.Value) (truth, ok bool) {
return hreflect.IsTruthfulValue(val), true
}