-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix broken pull request files #22962
Fix broken pull request files #22962
Conversation
@@ -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" $.Context "user" .Poster}} | |||
{{template "shared/user/avatarlink" Dict "Context" $.root.Context "user" .Poster}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between Dict "Context" $.root.Context
and Dict "ctx" $.root
? I can see Dict "ctx" $.root
below, which is using $.root
as the ctx directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dict "Context" $.root.Context
allows us to use $.Context
in the underlying template.
Dict "ctx" $.root
allows us to use $.ctx
in the underlying template.
This is a data map, Dict
could help to compose them into the data map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that basic knowledge.
I mean What's the difference between Dict "Context" $.root.Context
and Dict "ctx" $.root
?
Why not use Dict "Context" $.root
since the $.root
is also a context used widely in this template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we use Dict "Context" $.root
, then we need $.Context.Context
in the underlying template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I think I know the problem now.
$.root
is a map (not a Context interface), Dict "ctx" $.root
is passing the map as name ctx
, it's not a real context.
The naming is quite misleading .......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because: the passed in |
After this fix could be right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG-TM bot |
* upstream/main: Fix broken pull request files (go-gitea#22962) Fix avatar misalignment (go-gitea#22955) Refactor the setting to make unit test easier (go-gitea#22405) Migration v244.go should be v243.go (go-gitea#22988) Adjust manifest to prevent tagging latest on rcs (go-gitea#22811) Add some guidelines for refactoring (go-gitea#22880) Rename `GetUnits` to `LoadUnits` (go-gitea#22970) Provide the ability to set password hash algorithm parameters (go-gitea#22942) Fix no user listed in org teams page (go-gitea#22979) Refactor hiding-methods, remove jQuery show/hide, remove `.hide` class, remove inline style=display:none (go-gitea#22950) Scoped labels (go-gitea#22585) Rename "People" to "Members" in organization page and use a better icon (go-gitea#22960) Rename `repo.GetOwner` to `repo.LoadOwner` (go-gitea#22967) Notify on container image create (go-gitea#22806) webview: Fix overflowing diff body (go-gitea#22959) Introduce customized HTML elements, fix incorrect AppUrl usages in templates (go-gitea#22861) Sort issues and pulls by recently updated in user and organization home (go-gitea#22925) Fix 404 error viewing the LFS file (go-gitea#22945)
Before, the `dict "ctx" ...` map is used to pass data between templates. Now, more and more templates need to use real Go context: * #22962 * #23092 `ctx` is a Go concept for `Context`, misusing it may cause problems, and it makes it difficult to review or refactor. This PR contains 2 major changes: * In the top scope of a template, the `$` is the same as the `.`, so the old labels_sidebar's `root` is the `ctx`. So this `ctx` could just be removed. bd7f218 * Rename all other `ctx` to `ctxData`, and it perfectly matches how it comes from backend: `"ctxData": ctx.Data`. 7c01260 From now on, there is no `ctx` in templates. There are only: * `ctxData` for passing data * `Context` for Go context
Fix #22961