@@ -152,14 +152,15 @@ var TplFuncMap template.FuncMap = template.FuncMap{
152152 "Extension" : path .Ext ,
153153 "InExt" : InExt ,
154154
155- "Concat" : Concat ,
156- "Replace" : strings .Replace , //strings.Replace(s, old, new, n)
157- "Split" : strings .Split ,
158- "Join" : strings .Join ,
159- "Substr" : com .Substr ,
160- "StripTags" : com .StripTags ,
161- "Nl2br" : NlToBr , // \n替换为<br>
162- "AddSuffix" : AddSuffix ,
155+ "Concat" : Concat ,
156+ "Replace" : strings .Replace , //strings.Replace(s, old, new, n)
157+ "Split" : strings .Split ,
158+ "Join" : strings .Join ,
159+ "Substr" : com .Substr ,
160+ "StripTags" : com .StripTags ,
161+ "Nl2br" : NlToBr , // \n替换为<br>
162+ "AddSuffix" : AddSuffix ,
163+ "RandomString" : RandomString ,
163164
164165 // ======================
165166 // encode & decode
@@ -221,6 +222,13 @@ var (
221222 NumberFormat = com .NumberFormat
222223)
223224
225+ func RandomString (length ... uint ) string {
226+ if len (length ) > 0 && length [0 ] > 0 {
227+ return com .RandomAlphanumeric (length [0 ])
228+ }
229+ return com .RandomAlphanumeric (8 )
230+ }
231+
224232func Hash (text , salt string , positions ... uint ) string {
225233 if len (salt ) < 1 {
226234 salt = HashSalt
0 commit comments