mirror of
https://gitee.com/johng/gf
synced 2026-07-04 21:03:13 +08:00
fix issue in eq for package gview
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
@ -51,11 +51,11 @@ func (view *View) buildInFuncMaps(value ...interface{}) []map[string]interface{}
|
||||
func (view *View) buildInFuncEq(value interface{}, others ...interface{}) bool {
|
||||
s := gconv.String(value)
|
||||
for _, v := range others {
|
||||
if strings.Compare(s, gconv.String(v)) != 0 {
|
||||
return false
|
||||
if strings.Compare(s, gconv.String(v)) == 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
// buildInFuncNe implements build-in template function: ne
|
||||
|
||||
@ -175,6 +175,19 @@ func Test_Func(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
t.Assert(result, `ILoveGoFrame`)
|
||||
})
|
||||
// eq: multiple values.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
str := `{{eq 1 2 1 3 4 5}}`
|
||||
result, err := gview.ParseContent(str, nil)
|
||||
t.Assert(err != nil, false)
|
||||
t.Assert(result, `true`)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
str := `{{eq 6 2 1 3 4 5}}`
|
||||
result, err := gview.ParseContent(str, nil)
|
||||
t.Assert(err != nil, false)
|
||||
t.Assert(result, `false`)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_FuncNl2Br(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user