summaryrefslogtreecommitdiffstats
path: root/modules/templates/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates/helper.go')
-rw-r--r--modules/templates/helper.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 03e0e9899b..c0be5c1fa5 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -98,18 +98,19 @@ func NewFuncMap() []template.FuncMap {
"CustomEmojis": func() map[string]string {
return setting.UI.CustomEmojisMap
},
- "Safe": Safe,
- "SafeJS": SafeJS,
- "JSEscape": JSEscape,
- "Str2html": Str2html,
- "TimeSince": timeutil.TimeSince,
- "TimeSinceUnix": timeutil.TimeSinceUnix,
- "RawTimeSince": timeutil.RawTimeSince,
- "FileSize": base.FileSize,
- "PrettyNumber": base.PrettyNumber,
- "Subtract": base.Subtract,
- "EntryIcon": base.EntryIcon,
- "MigrationIcon": MigrationIcon,
+ "Safe": Safe,
+ "SafeJS": SafeJS,
+ "JSEscape": JSEscape,
+ "Str2html": Str2html,
+ "TimeSince": timeutil.TimeSince,
+ "TimeSinceUnix": timeutil.TimeSinceUnix,
+ "RawTimeSince": timeutil.RawTimeSince,
+ "FileSize": base.FileSize,
+ "PrettyNumber": base.PrettyNumber,
+ "JsPrettyNumber": JsPrettyNumber,
+ "Subtract": base.Subtract,
+ "EntryIcon": base.EntryIcon,
+ "MigrationIcon": MigrationIcon,
"Add": func(a ...int) int {
sum := 0
for _, val := range a {
@@ -1005,3 +1006,11 @@ func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteNa
return a
}
+
+// JsPrettyNumber renders a number using english decimal separators, e.g. 1,200 and subsequent
+// JS will replace the number with locale-specific separators, based on the user's selected language
+func JsPrettyNumber(i interface{}) template.HTML {
+ num := util.NumberIntoInt64(i)
+
+ return template.HTML(`<span class="js-pretty-number" data-value="` + strconv.FormatInt(num, 10) + `">` + base.PrettyNumber(num) + `</span>`)
+}