From a2f13eae559c71d35662b7767a8b8347a26eb53e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 5 Mar 2016 00:51:51 -0500 Subject: #1157 some avatar setting changes - Allow to delete current avatar --- modules/base/tool.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index bc6ff81a14..45d0aea5bc 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -464,6 +464,15 @@ func EllipsisString(str string, length int) string { return str[:length-3] + "..." } +// TruncateString returns a truncated string with given limit, +// it returns input string if length is not reached limit. +func TruncateString(str string, limit int) string { + if len(str) < limit { + return str + } + return str[:limit] +} + // StringsToInt64s converts a slice of string to a slice of int64. func StringsToInt64s(strs []string) []int64 { ints := make([]int64, len(strs)) -- cgit v1.2.3