mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
ee31e61fb0
commit
ae383f04c8
2 changed files with 13 additions and 5 deletions
|
@ -292,14 +292,19 @@ func (ns *Namespace) In(l interface{}, v interface{}) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
}
|
||||
case reflect.String:
|
||||
if vv.Type() == lv.Type() && strings.Contains(lv.String(), vv.String()) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
ss, err := cast.ToStringE(l)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
su, err := cast.ToStringE(v)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
return strings.Contains(ss, su), nil
|
||||
}
|
||||
|
||||
// Intersect returns the common elements in the given sets, l1 and l2. l1 and
|
||||
// l2 must be of the same type and may be either arrays or slices.
|
||||
func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error) {
|
||||
|
|
|
@ -345,6 +345,9 @@ func TestIn(t *testing.T) {
|
|||
// Structs
|
||||
{pagesVals{p3v, p2v, p3v, p2v}, p2v, true},
|
||||
{pagesVals{p3v, p2v, p3v, p2v}, p4v, false},
|
||||
// template.HTML
|
||||
{template.HTML("this substring should be found"), "substring", true},
|
||||
{template.HTML("this substring should not be found"), "subseastring", false},
|
||||
} {
|
||||
|
||||
errMsg := qt.Commentf("[%d] %v", i, test)
|
||||
|
|
Loading…
Reference in a new issue