summaryrefslogtreecommitdiffstats
path: root/tpl/internal
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-18 16:50:34 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-18 20:05:22 +0100
commitd20ca3700512d661247b44d953515b9455e57ed6 (patch)
tree2db72cf0bc6246e1c28106942af6b1e6f679e4e1 /tpl/internal
parent3e316155c5d4fbf166d38e997a41101b6aa501d5 (diff)
tpl: Get rid of the custom template truth logic
Fixes #6615
Diffstat (limited to 'tpl/internal')
-rw-r--r--tpl/internal/go_templates/texttemplate/exec.go2
-rw-r--r--tpl/internal/go_templates/texttemplate/hugo_template.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/tpl/internal/go_templates/texttemplate/exec.go b/tpl/internal/go_templates/texttemplate/exec.go
index 078bcf643..f400abd9c 100644
--- a/tpl/internal/go_templates/texttemplate/exec.go
+++ b/tpl/internal/go_templates/texttemplate/exec.go
@@ -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
diff --git a/tpl/internal/go_templates/texttemplate/hugo_template.go b/tpl/internal/go_templates/texttemplate/hugo_template.go
index a39f027fb..d881064e5 100644
--- a/tpl/internal/go_templates/texttemplate/hugo_template.go
+++ b/tpl/internal/go_templates/texttemplate/hugo_template.go
@@ -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
+}