From 9b023979789c0c3fd3bb4eef50518937f0c54879 Mon Sep 17 00:00:00 2001 From: akuma06 Date: Sun, 21 May 2017 13:55:29 +0200 Subject: [PATCH] Add filesize function --- router/template_functions.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/router/template_functions.go b/router/template_functions.go index 18658024..9889a77c 100644 --- a/router/template_functions.go +++ b/router/template_functions.go @@ -11,6 +11,8 @@ import ( "github.com/NyaaPantsu/nyaa/config" "github.com/NyaaPantsu/nyaa/service/user/permission" "github.com/NyaaPantsu/nyaa/util/languages" + + "github.com/nicksnyder/go-i18n/i18n" ) var FuncMap = template.FuncMap{ @@ -203,4 +205,10 @@ var FuncMap = template.FuncMap{ } return e }, + "fileSize": func(filesize string, T i18n.TranslateFunc) string { + if (filesize == "Unknown") { + return T("unknown") + } + return filesize + }, }