Simplify template helper functions (#24570)
To avoid bloating the template helper functions, some functions could be provided by type methods. And the new code `data-line-type="{{.GetHTMLDiffLineType}}"` reads better than `data-line-type="{{DiffLineTypeToStr .GetType}}"` After the fix, screenshots (the same as before): <details>   </details>
This commit is contained in:
parent
377e0139b0
commit
56ae853ca0
6 changed files with 20 additions and 21 deletions
|
@ -179,7 +179,6 @@ func NewFuncMap() template.FuncMap {
|
|||
|
||||
// -----------------------------------------------------------------
|
||||
// misc
|
||||
"DiffLineTypeToStr": DiffLineTypeToStr,
|
||||
"ShortSha": base.ShortSha,
|
||||
"ActionContent2Commits": ActionContent2Commits,
|
||||
"IsMultilineCommitMessage": IsMultilineCommitMessage,
|
||||
|
|
|
@ -122,19 +122,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
|
|||
return push
|
||||
}
|
||||
|
||||
// DiffLineTypeToStr returns diff line type name
|
||||
func DiffLineTypeToStr(diffType int) string {
|
||||
switch diffType {
|
||||
case 2:
|
||||
return "add"
|
||||
case 3:
|
||||
return "del"
|
||||
case 4:
|
||||
return "tag"
|
||||
}
|
||||
return "same"
|
||||
}
|
||||
|
||||
// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
|
||||
func MigrationIcon(hostname string) string {
|
||||
switch hostname {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue