@@ -19,7 +19,6 @@ import (
19
19
"reflect"
20
20
"regexp"
21
21
"runtime"
22
- "strconv"
23
22
"strings"
24
23
texttmpl "text/template"
25
24
"time"
@@ -112,18 +111,17 @@ func NewFuncMap() []template.FuncMap {
112
111
"IsShowFullName" : func () bool {
113
112
return setting .UI .DefaultShowFullName
114
113
},
115
- "Safe" : Safe ,
116
- "SafeJS" : SafeJS ,
117
- "JSEscape" : JSEscape ,
118
- "Str2html" : Str2html ,
119
- "TimeSince" : timeutil .TimeSince ,
120
- "TimeSinceUnix" : timeutil .TimeSinceUnix ,
121
- "FileSize" : base .FileSize ,
122
- "PrettyNumber" : base .PrettyNumber ,
123
- "JsPrettyNumber" : JsPrettyNumber ,
124
- "Subtract" : base .Subtract ,
125
- "EntryIcon" : base .EntryIcon ,
126
- "MigrationIcon" : MigrationIcon ,
114
+ "Safe" : Safe ,
115
+ "SafeJS" : SafeJS ,
116
+ "JSEscape" : JSEscape ,
117
+ "Str2html" : Str2html ,
118
+ "TimeSince" : timeutil .TimeSince ,
119
+ "TimeSinceUnix" : timeutil .TimeSinceUnix ,
120
+ "FileSize" : base .FileSize ,
121
+ "LocaleNumber" : LocaleNumber ,
122
+ "Subtract" : base .Subtract ,
123
+ "EntryIcon" : base .EntryIcon ,
124
+ "MigrationIcon" : MigrationIcon ,
127
125
"Add" : func (a ... int ) int {
128
126
sum := 0
129
127
for _ , val := range a {
@@ -410,62 +408,9 @@ func NewFuncMap() []template.FuncMap {
410
408
"Join" : strings .Join ,
411
409
"QueryEscape" : url .QueryEscape ,
412
410
"DotEscape" : DotEscape ,
413
- "Iterate" : func (arg interface {}) (items []uint64 ) {
414
- count := uint64 (0 )
415
- switch val := arg .(type ) {
416
- case uint64 :
417
- count = val
418
- case * uint64 :
419
- count = * val
420
- case int64 :
421
- if val < 0 {
422
- val = 0
423
- }
424
- count = uint64 (val )
425
- case * int64 :
426
- if * val < 0 {
427
- * val = 0
428
- }
429
- count = uint64 (* val )
430
- case int :
431
- if val < 0 {
432
- val = 0
433
- }
434
- count = uint64 (val )
435
- case * int :
436
- if * val < 0 {
437
- * val = 0
438
- }
439
- count = uint64 (* val )
440
- case uint :
441
- count = uint64 (val )
442
- case * uint :
443
- count = uint64 (* val )
444
- case int32 :
445
- if val < 0 {
446
- val = 0
447
- }
448
- count = uint64 (val )
449
- case * int32 :
450
- if * val < 0 {
451
- * val = 0
452
- }
453
- count = uint64 (* val )
454
- case uint32 :
455
- count = uint64 (val )
456
- case * uint32 :
457
- count = uint64 (* val )
458
- case string :
459
- cnt , _ := strconv .ParseInt (val , 10 , 64 )
460
- if cnt < 0 {
461
- cnt = 0
462
- }
463
- count = uint64 (cnt )
464
- }
465
- if count <= 0 {
466
- return items
467
- }
468
- for i := uint64 (0 ); i < count ; i ++ {
411
+ "Iterate" : func (arg interface {}) (items []int64 ) {
412
+ count := util .ToInt64 (arg )
413
+ for i := int64 (0 ); i < count ; i ++ {
469
414
items = append (items , i )
470
415
}
471
416
return items
@@ -1067,10 +1012,8 @@ func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteNa
1067
1012
return a
1068
1013
}
1069
1014
1070
- // JsPrettyNumber renders a number using english decimal separators, e.g. 1,200 and subsequent
1071
- // JS will replace the number with locale-specific separators, based on the user's selected language
1072
- func JsPrettyNumber (i interface {}) template.HTML {
1073
- num := util .NumberIntoInt64 (i )
1074
-
1075
- return template .HTML (`<span class="js-pretty-number" data-value="` + strconv .FormatInt (num , 10 ) + `">` + base .PrettyNumber (num ) + `</span>` )
1015
+ // LocaleNumber renders a number with a Custom Element, browser will render it with a locale number
1016
+ func LocaleNumber (v interface {}) template.HTML {
1017
+ num := util .ToInt64 (v )
1018
+ return template .HTML (fmt .Sprintf (`<gitea-locale-number data-number="%d">%d</gitea-locale-number>` , num , num ))
1076
1019
}
0 commit comments