Skip to content

Commit 46bde2f

Browse files
committed
make template conditional on details
1 parent b7d696d commit 46bde2f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

routers/web/repo/pull.go

-2
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13561356
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
13571357
"Message": ctx.Tr("repo.pulls.push_rejected"),
13581358
"Summary": ctx.Tr("repo.pulls.new.blocked_user"),
1359-
"Details": "",
13601359
})
13611360
if err != nil {
13621361
ctx.ServerError("CompareAndPullRequest.HTMLString", err)
@@ -1367,7 +1366,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13671366
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
13681367
"Message": ctx.Tr("repo.pulls.push_rejected"),
13691368
"Summary": ctx.Tr("repo.pulls.new.must_collaborator"),
1370-
"Details": "",
13711369
})
13721370
if err != nil {
13731371
ctx.ServerError("CompareAndPullRequest.HTMLString", err)

templates/base/alert_details.tmpl

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{{.Message}}
2+
{{ if .Details }}
23
<details>
34
<summary>{{.Summary}}</summary>
4-
<code>
5-
{{.Details | SanitizeHTML}}
6-
</code>
5+
<code>{{.Details | SanitizeHTML}}</code>
76
</details>
7+
{{ else }}
8+
<div>
9+
{{ .Summary }}
10+
</div>
11+
{{ end }}

0 commit comments

Comments
 (0)