@@ -36,16 +36,16 @@ func NewFuncMap() template.FuncMap {
3636 // -----------------------------------------------------------------
3737 // html/template related functions
3838 "dict" : dict , // it's lowercase because this name has been widely used. Our other functions should have uppercase names.
39- "Iif" : Iif ,
40- "Eval" : Eval ,
41- "SafeHTML" : SafeHTML ,
39+ "Iif" : iif ,
40+ "Eval" : evalTokens ,
41+ "SafeHTML" : safeHTML ,
4242 "HTMLFormat" : HTMLFormat ,
43- "HTMLEscape" : HTMLEscape ,
44- "QueryEscape" : QueryEscape ,
45- "JSEscape" : JSEscapeSafe ,
43+ "HTMLEscape" : htmlEscape ,
44+ "QueryEscape" : queryEscape ,
45+ "JSEscape" : jsEscapeSafe ,
4646 "SanitizeHTML" : SanitizeHTML ,
4747 "URLJoin" : util .URLJoin ,
48- "DotEscape" : DotEscape ,
48+ "DotEscape" : dotEscape ,
4949
5050 "PathEscape" : url .PathEscape ,
5151 "PathEscapeSegments" : util .PathEscapeSegments ,
@@ -59,9 +59,9 @@ func NewFuncMap() template.FuncMap {
5959 // svg / avatar / icon / color
6060 "svg" : svg .RenderHTML ,
6161 "EntryIcon" : base .EntryIcon ,
62- "MigrationIcon" : MigrationIcon ,
63- "ActionIcon" : ActionIcon ,
64- "SortArrow" : SortArrow ,
62+ "MigrationIcon" : migrationIcon ,
63+ "ActionIcon" : actionIcon ,
64+ "SortArrow" : sortArrow ,
6565 "ContrastColor" : util .ContrastColor ,
6666
6767 // -----------------------------------------------------------------
@@ -139,7 +139,7 @@ func NewFuncMap() template.FuncMap {
139139 "DisableImportLocal" : func () bool {
140140 return ! setting .ImportLocalPaths
141141 },
142- "UserThemeName" : UserThemeName ,
142+ "UserThemeName" : userThemeName ,
143143 "NotificationSettings" : func () map [string ]any {
144144 return map [string ]any {
145145 "MinTimeout" : int (setting .UI .Notification .MinTimeout / time .Millisecond ),
@@ -155,28 +155,28 @@ func NewFuncMap() template.FuncMap {
155155 // -----------------------------------------------------------------
156156 // render
157157 "RenderCommitMessage" : RenderCommitMessage ,
158- "RenderCommitMessageLinkSubject" : RenderCommitMessageLinkSubject ,
158+ "RenderCommitMessageLinkSubject" : renderCommitMessageLinkSubject ,
159159
160- "RenderCommitBody" : RenderCommitBody ,
161- "RenderCodeBlock" : RenderCodeBlock ,
162- "RenderIssueTitle" : RenderIssueTitle ,
163- "RenderEmoji" : RenderEmoji ,
164- "ReactionToEmoji" : ReactionToEmoji ,
160+ "RenderCommitBody" : renderCommitBody ,
161+ "RenderCodeBlock" : renderCodeBlock ,
162+ "RenderIssueTitle" : renderIssueTitle ,
163+ "RenderEmoji" : renderEmoji ,
164+ "ReactionToEmoji" : reactionToEmoji ,
165165
166166 "RenderMarkdownToHtml" : RenderMarkdownToHtml ,
167- "RenderLabel" : RenderLabel ,
167+ "RenderLabel" : renderLabel ,
168168 "RenderLabels" : RenderLabels ,
169169
170170 // -----------------------------------------------------------------
171171 // misc
172172 "ShortSha" : base .ShortSha ,
173173 "ActionContent2Commits" : ActionContent2Commits ,
174- "IsMultilineCommitMessage" : IsMultilineCommitMessage ,
174+ "IsMultilineCommitMessage" : isMultilineCommitMessage ,
175175 "CommentMustAsDiff" : gitdiff .CommentMustAsDiff ,
176176 "MirrorRemoteAddress" : mirrorRemoteAddress ,
177177
178- "FilenameIsImage" : FilenameIsImage ,
179- "TabSizeClass" : TabSizeClass ,
178+ "FilenameIsImage" : filenameIsImage ,
179+ "TabSizeClass" : tabSizeClass ,
180180 }
181181}
182182
@@ -197,8 +197,8 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML {
197197 return template .HTML (fmt .Sprintf (s , args ... ))
198198}
199199
200- // SafeHTML render raw as HTML
201- func SafeHTML (s any ) template.HTML {
200+ // safeHTML render raw as HTML
201+ func safeHTML (s any ) template.HTML {
202202 switch v := s .(type ) {
203203 case string :
204204 return template .HTML (v )
@@ -213,7 +213,7 @@ func SanitizeHTML(s string) template.HTML {
213213 return template .HTML (markup .Sanitize (s ))
214214}
215215
216- func HTMLEscape (s any ) template.HTML {
216+ func htmlEscape (s any ) template.HTML {
217217 switch v := s .(type ) {
218218 case string :
219219 return template .HTML (html .EscapeString (v ))
@@ -223,22 +223,22 @@ func HTMLEscape(s any) template.HTML {
223223 panic (fmt .Sprintf ("unexpected type %T" , s ))
224224}
225225
226- func JSEscapeSafe (s string ) template.HTML {
226+ func jsEscapeSafe (s string ) template.HTML {
227227 return template .HTML (template .JSEscapeString (s ))
228228}
229229
230- func QueryEscape (s string ) template.URL {
230+ func queryEscape (s string ) template.URL {
231231 return template .URL (url .QueryEscape (s ))
232232}
233233
234- // DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
235- func DotEscape (raw string ) string {
234+ // dotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent auto-linkers from detecting these as urls
235+ func dotEscape (raw string ) string {
236236 return strings .ReplaceAll (raw , "." , "\u200d .\u200d " )
237237}
238238
239- // Iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
240- // and it could be simply used as "{{Iif expr trueVal}}" (omit the falseVal).
241- func Iif (condition any , vals ... any ) any {
239+ // iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
240+ // and it could be simply used as "{{iif expr trueVal}}" (omit the falseVal).
241+ func iif (condition any , vals ... any ) any {
242242 if isTemplateTruthy (condition ) {
243243 return vals [0 ]
244244 } else if len (vals ) > 1 {
@@ -273,19 +273,19 @@ func isTemplateTruthy(v any) bool {
273273 }
274274}
275275
276- // Eval the expression and return the result, see the comment of eval.Expr for details.
276+ // evalTokens evaluates the expression by tokens and returns the result, see the comment of eval.Expr for details.
277277// To use this helper function in templates, pass each token as a separate parameter.
278278//
279279// {{ $int64 := Eval $var "+" 1 }}
280280// {{ $float64 := Eval $var "+" 1.0 }}
281281//
282282// Golang's template supports comparable int types, so the int64 result can be used in later statements like {{if lt $int64 10}}
283- func Eval (tokens ... any ) (any , error ) {
283+ func evalTokens (tokens ... any ) (any , error ) {
284284 n , err := eval .Expr (tokens ... )
285285 return n .Value , err
286286}
287287
288- func UserThemeName (user * user_model.User ) string {
288+ func userThemeName (user * user_model.User ) string {
289289 if user == nil || user .Theme == "" {
290290 return setting .UI .DefaultTheme
291291 }
0 commit comments