diff options
author | Bjørn Erik Pedersen <[email protected]> | 2020-01-23 10:48:28 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-01-23 10:48:28 +0100 |
commit | 2fefc01606fddb119f368c89fb2dedd452ad6547 (patch) | |
tree | 2b498123453b3002e7c3f628afe73f2ab9d33646 | |
parent | 0c251be66bf3ad4abafbc47583e394ca4e6ffcf1 (diff) | |
download | hugo-2fefc01606fddb119f368c89fb2dedd452ad6547.tar.gz hugo-2fefc01606fddb119f368c89fb2dedd452ad6547.zip |
tpl/compare: Fix eq when > 2 args
Fixes #6786
-rw-r--r-- | tpl/compare/compare.go | 10 | ||||
-rw-r--r-- | tpl/compare/compare_test.go | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/tpl/compare/compare.go b/tpl/compare/compare.go index b5b99ff9a..e005aff06 100644 --- a/tpl/compare/compare.go +++ b/tpl/compare/compare.go @@ -119,11 +119,17 @@ func (n *Namespace) Eq(first interface{}, others ...interface{}) bool { normFirst := normalize(first) for _, other := range others { if e, ok := first.(compare.Eqer); ok { - return e.Eq(other) + if e.Eq(other) { + return true + } + continue } if e, ok := other.(compare.Eqer); ok { - return e.Eq(first) + if e.Eq(first) { + return true + } + continue } other = normalize(other) diff --git a/tpl/compare/compare_test.go b/tpl/compare/compare_test.go index aeadb02f9..3eb793d30 100644 --- a/tpl/compare/compare_test.go +++ b/tpl/compare/compare_test.go @@ -275,6 +275,9 @@ func TestEqualExtend(t *testing.T) { {1, []interface{}{1, 2}, true}, {1, []interface{}{2, 1}, true}, {1, []interface{}{2, 3}, false}, + {tstEqerType1("a"), []interface{}{tstEqerType1("a"), tstEqerType1("b")}, true}, + {tstEqerType1("a"), []interface{}{tstEqerType1("b"), tstEqerType1("a")}, true}, + {tstEqerType1("a"), []interface{}{tstEqerType1("b"), tstEqerType1("c")}, false}, } { result := ns.Eq(test.first, test.others...) |