diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-07 22:39:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 09:39:08 -0500 |
commit | 36c0840cf1696912b1872cfa4ebc4b241dabd693 (patch) | |
tree | c3951e2bb0f1723043bd7fdcec0ab50c19d6ef3e /templates/repo/diff | |
parent | 5b89670a318e52e271f65d96bfe1116d85d20988 (diff) | |
download | gitea-36c0840cf1696912b1872cfa4ebc4b241dabd693.tar.gz gitea-36c0840cf1696912b1872cfa4ebc4b241dabd693.zip |
Merge template functions "dict/Dict/mergeinto" (#23932)
One of the steps in #23328
Before there were 3 different but similar functions: dict/Dict/mergeinto
The code was just copied & pasted, no test.
This PR defines a new stable `dict` function, it covers all the 3 old
functions behaviors, only +160 -171
Future developers do not need to think about or guess the different dict
functions, just use one: `dict`
Why use `dict` but not `Dict`? Because there are far more `dict` than
`Dict` in code already ......
Diffstat (limited to 'templates/repo/diff')
-rw-r--r-- | templates/repo/diff/comments.tmpl | 8 | ||||
-rw-r--r-- | templates/repo/diff/section_split.tmpl | 12 | ||||
-rw-r--r-- | templates/repo/diff/section_unified.tmpl | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index c14b145a37..5c26e7815f 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -5,7 +5,7 @@ {{if .OriginalAuthor}} <span class="avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span> {{else}} - {{template "shared/user/avatarlink" Dict "Context" $.root.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "Context" $.root.Context "user" .Poster}} {{end}} <div class="content comment-container"> <div class="ui top attached header comment-header gt-df gt-ac gt-sb"> @@ -42,8 +42,8 @@ </div> {{end}} {{end}} - {{template "repo/issue/view_content/add_reaction" Dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctxData" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}} </div> </div> <div class="ui attached segment comment-body"> @@ -60,7 +60,7 @@ {{$reactions := .Reactions.GroupByType}} {{if $reactions}} <div class="ui attached segment reactions"> - {{template "repo/issue/view_content/reactions" Dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}} </div> {{end}} </div> diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index 4fa81f4e62..e44c2a0f73 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -111,22 +111,22 @@ <td class="add-comment-left" colspan="4"> {{if gt (len $line.Comments) 0}} {{if eq $line.GetCommentSide "previous"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} {{end}} {{if gt (len $match.Comments) 0}} {{if eq $match.GetCommentSide "previous"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $match.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{end}} {{end}} </td> <td class="add-comment-right" colspan="4"> {{if eq $line.GetCommentSide "proposed"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} {{if gt (len $match.Comments) 0}} {{if eq $match.GetCommentSide "proposed"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $match.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{end}} {{end}} </td> @@ -137,13 +137,13 @@ <td class="add-comment-left" colspan="4"> {{if gt (len $line.Comments) 0}} {{if eq $line.GetCommentSide "previous"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} {{end}} </td> <td class="add-comment-right" colspan="4"> {{if eq $line.GetCommentSide "proposed"}} - {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} </td> </tr> diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index ba4ad5b513..cdd2c26f81 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -57,7 +57,7 @@ {{if gt (len $line.Comments) 0}} <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}"> <td class="add-comment-left add-comment-right" colspan="5"> - {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} </td> </tr> {{end}} |