Skip to content
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

Merged
merged 3 commits into from
Feb 20, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/repo/diff/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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 .......

{{end}}
<div class="content comment-container">
<div class="ui top attached header comment-header gt-df gt-ac gt-sb">
Expand Down