Skip to content

Commit 7e40149

Browse files
committed
add ctx.HTMLString
1 parent 110bc5d commit 7e40149

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

routers/web/repo/editor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func DiffPreviewPost(ctx *context.Context) {
420420
}
421421

422422
if diff.NumFiles == 0 {
423-
ctx.PlainText(http.StatusOK, `<div class="tw-p-6">`+ctx.Locale.TrString("repo.editor.no_changes_to_show")+`</div>`)
423+
ctx.HTMLString(http.StatusOK, `<div class="tw-p-6">`+ctx.Locale.TrString("repo.editor.no_changes_to_show")+`</div>`)
424424
return
425425
}
426426
ctx.Data["File"] = diff.Files[0]

services/context/base.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ func (b *Base) JSON(status int, content any) {
137137
}
138138
}
139139

140+
// JSON render content as JSON
141+
func (b *Base) HTMLString(status int, html string) {
142+
b.Resp.Header().Set("Content-Type", "text/html;charset=utf-8")
143+
b.Resp.WriteHeader(status);
144+
b.Resp.Write([]byte(html))
145+
}
146+
140147
// RemoteAddr returns the client machine ip address
141148
func (b *Base) RemoteAddr() string {
142149
return b.Req.RemoteAddr

0 commit comments

Comments
 (0)