|
@@ -2,6 +2,8 @@ package funcmap
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "log"
|
|
|
+ "reflect"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
"text/template"
|
|
@@ -10,10 +12,6 @@ import (
|
|
|
"gogs.carducci-dante.gov.it/karmen/core/orm"
|
|
|
)
|
|
|
|
|
|
-type Stringer interface {
|
|
|
- String() string
|
|
|
-}
|
|
|
-
|
|
|
var FuncMap template.FuncMap = template.FuncMap{
|
|
|
"comma": comma,
|
|
|
"groupClasses": groupClasses,
|
|
@@ -32,23 +30,19 @@ func order(items []string) []string {
|
|
|
}
|
|
|
|
|
|
func stringSlice(items interface{}) []string {
|
|
|
- // var (
|
|
|
- // interfaces []interface{}
|
|
|
- // result []string
|
|
|
- // )
|
|
|
-
|
|
|
- // val := reflect.ValueOf(items)
|
|
|
- // interfaces = make([]interface{}, val.Len())
|
|
|
-
|
|
|
- // for i := 0; i < val.Len(); i++ {
|
|
|
- // interfaces = append(interfaces, items[i])
|
|
|
- // }
|
|
|
- // for _, i := range interfaces {
|
|
|
- // result = append(result, i.(Stringer).String())
|
|
|
- // }
|
|
|
-
|
|
|
- // return result
|
|
|
- return []string{}
|
|
|
+ var result []string
|
|
|
+
|
|
|
+ switch reflect.TypeOf(items).Kind() {
|
|
|
+ case reflect.Slice:
|
|
|
+ s := reflect.ValueOf(items)
|
|
|
+ for i := 0; i < s.Len(); i++ {
|
|
|
+ result = append(result, fmt.Sprintf("%s", s.Index(i)))
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ log.Println("Unknown type")
|
|
|
+ }
|
|
|
+
|
|
|
+ return result
|
|
|
}
|
|
|
|
|
|
func toUpper(content string) string {
|