@@ -15,7 +15,6 @@ import (
15
15
"mime"
16
16
"net/url"
17
17
"path/filepath"
18
- "reflect"
19
18
"regexp"
20
19
"strings"
21
20
"time"
@@ -68,11 +67,15 @@ func NewFuncMap() []template.FuncMap {
68
67
"PathEscape" : url .PathEscape ,
69
68
"PathEscapeSegments" : util .PathEscapeSegments ,
70
69
70
+ // utils
71
+ "StringUtils" : NewStringUtils ,
72
+ "SliceUtils" : NewSliceUtils ,
73
+
71
74
// -----------------------------------------------------------------
72
75
// string / json
76
+ // TODO: move string helper functions to StringUtils
73
77
"Join" : strings .Join ,
74
78
"DotEscape" : DotEscape ,
75
- "HasPrefix" : strings .HasPrefix ,
76
79
"EllipsisString" : base .EllipsisString ,
77
80
78
81
"Json" : func (in interface {}) string {
@@ -143,35 +146,6 @@ func NewFuncMap() []template.FuncMap {
143
146
return fmt .Sprint (time .Since (startTime ).Nanoseconds ()/ 1e6 ) + "ms"
144
147
},
145
148
146
- // -----------------------------------------------------------------
147
- // slice
148
- "containGeneric" : func (arr , v interface {}) bool {
149
- arrV := reflect .ValueOf (arr )
150
- if arrV .Kind () == reflect .String && reflect .ValueOf (v ).Kind () == reflect .String {
151
- return strings .Contains (arr .(string ), v .(string ))
152
- }
153
- if arrV .Kind () == reflect .Slice {
154
- for i := 0 ; i < arrV .Len (); i ++ {
155
- iV := arrV .Index (i )
156
- if ! iV .CanInterface () {
157
- continue
158
- }
159
- if iV .Interface () == v {
160
- return true
161
- }
162
- }
163
- }
164
- return false
165
- },
166
- "contain" : func (s []int64 , id int64 ) bool {
167
- for i := 0 ; i < len (s ); i ++ {
168
- if s [i ] == id {
169
- return true
170
- }
171
- }
172
- return false
173
- },
174
-
175
149
// -----------------------------------------------------------------
176
150
// setting
177
151
"AppName" : func () string {
0 commit comments