Revert "tplimpl: return an error on unsupported type in isSet"

This breaks the theme site and lots of themes, so we will have to thinkg a little harder about this one.

This reverts commit 74ea81b885.
This commit is contained in:
Bjørn Erik Pedersen
2017-03-26 20:07:15 +02:00
parent 1b92c8b713
commit 2bea9d0ca1
2 changed files with 10 additions and 30 deletions

View File

@@ -1325,24 +1325,22 @@ func (p pairList) sort() interface{} {
// isSet returns whether a given array, channel, slice, or map has a key
// defined.
func isSet(a interface{}, key interface{}) (bool, error) {
func isSet(a interface{}, key interface{}) bool {
av := reflect.ValueOf(a)
kv := reflect.ValueOf(key)
switch av.Kind() {
case reflect.Array, reflect.Chan, reflect.Slice:
if int64(av.Len()) > kv.Int() {
return true, nil
return true
}
case reflect.Map:
if kv.Type() == av.Type().Key() {
return av.MapIndex(kv).IsValid(), nil
return av.MapIndex(kv).IsValid()
}
default:
return false, fmt.Errorf("unsupported type %q", av.Kind())
}
return false, nil
return false
}
// returnWhenSet returns a given value if it set. Otherwise, it returns an