mirror of
https://github.com/go-gitea/gitea
synced 2024-11-15 22:54:24 +00:00
30708d9ffe
Backport #16956 The mail template rendering was failing with the error - `...vices/mailer/mail.go:301:composeIssueCommentMessages() [E] ExecuteTemplate [issue/default/body]: template: issue/default:65:10: executing "issue/default" at <.i18n.Tr>: can't evaluate field i18n in type *models.Comment` The issue was the template variable i18n is available in the outer scope. Fix #16877 Co-authored-by: 6543 <6543@obermui.de>
93 lines
3.4 KiB
Handlebars
93 lines
3.4 KiB
Handlebars
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>{{.Subject}}</title>
|
|
|
|
<style>
|
|
blockquote { padding-left: 1em; margin: 1em 0; border-left: 1px solid grey; color: #777}
|
|
.footer { font-size:small; color:#666;}
|
|
{{if .ReviewComments}}
|
|
.review { padding-left: 1em; margin: 1em 0; }
|
|
.review > pre { padding: 1em; border-left: 1px solid grey; }
|
|
{{end}}
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
{{if .IsMention}}<p>{{.i18n.Tr "mail.issue.x_mentioned_you" .Doer.Name | Str2html}}</p>{{end}}
|
|
{{if eq .ActionName "push"}}
|
|
<p>
|
|
{{if .Comment.IsForcePush}}
|
|
{{$oldCommitUrl := printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.OldCommit}}
|
|
{{$oldShortSha := ShortSha .Comment.OldCommit}}
|
|
{{$oldCommitLink := printf "<a href='%[1]s'><b>%[2]s</b></a>" $oldCommitUrl $oldShortSha}}
|
|
|
|
{{$newCommitUrl := printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.NewCommit}}
|
|
{{$newShortSha := ShortSha .Comment.NewCommit}}
|
|
{{$newCommitLink := printf "<a href='%[1]s'><b>%[2]s</b></a>" $newCommitUrl $newShortSha}}
|
|
|
|
{{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}}
|
|
{{else}}
|
|
{{.i18n.Tr (TrN .i18n.Lang .Comment.Commits.Len "mail.issue.action.push_1" "mail.issue.action.push_n") .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}}
|
|
{{end}}
|
|
</p>
|
|
{{end}}
|
|
<p>
|
|
{{if eq .ActionName "close"}}
|
|
{{.i18n.Tr "mail.issue.action.close" .Doer.Name .Issue.Index | Str2html}}
|
|
{{else if eq .ActionName "reopen"}}
|
|
{{.i18n.Tr "mail.issue.action.reopen" .Doer.Name .Issue.Index | Str2html}}
|
|
{{else if eq .ActionName "merge"}}
|
|
{{.i18n.Tr "mail.issue.action.merge" .Doer.Name .Issue.Index .Issue.PullRequest.BaseBranch | Str2html}}
|
|
{{else if eq .ActionName "approve"}}
|
|
{{.i18n.Tr "mail.issue.action.approve" .Doer.Name | Str2html}}
|
|
{{else if eq .ActionName "reject"}}
|
|
{{.i18n.Tr "mail.issue.action.reject" .Doer.Name | Str2html}}
|
|
{{else if eq .ActionName "review"}}
|
|
{{.i18n.Tr "mail.issue.action.review" .Doer.Name | Str2html}}
|
|
{{else if eq .ActionName "review_dismissed"}}
|
|
{{.i18n.Tr "mail.issue.action.review_dismissed" .Doer.Name .Comment.Review.Reviewer.Name | Str2html}}
|
|
{{else if eq .ActionName "ready_for_review"}}
|
|
{{.i18n.Tr "mail.issue.action.ready_for_review" .Doer.Name | Str2html}}
|
|
{{end}}
|
|
|
|
{{- if eq .Body ""}}
|
|
{{if eq .ActionName "new"}}
|
|
{{.i18n.Tr "mail.issue.action.new" .Doer.Name .Issue.Index | Str2html}}
|
|
{{end}}
|
|
{{else}}
|
|
{{.Body | Str2html}}
|
|
{{end -}}
|
|
{{- range .ReviewComments}}
|
|
<hr>
|
|
{{$.i18n.Tr "mail.issue.in_tree_path" .TreePath}}
|
|
<div class="review">
|
|
<pre>{{.Patch}}</pre>
|
|
<div>{{.RenderedContent | Safe}}</div>
|
|
</div>
|
|
{{end -}}
|
|
{{if eq .ActionName "push"}}
|
|
{{ $r:= List .Comment.Commits}}
|
|
<ul>
|
|
{{range $r}}
|
|
<li>
|
|
<a href="{{AppUrl}}{{$.Comment.Issue.PullRequest.BaseRepo.OwnerName}}/{{$.Comment.Issue.PullRequest.BaseRepo.Name}}/commit/{{.ID}}">
|
|
{{ShortSha .ID.String}}
|
|
</a> - {{.Summary}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
{{end}}
|
|
</p>
|
|
<div class="footer">
|
|
<p>
|
|
---
|
|
<br>
|
|
<a href="{{.Link}}">{{.i18n.Tr "mail.view_it_on" AppName}}</a>.
|
|
</p>
|
|
</div>
|
|
</body>
|
|
</html>
|