summaryrefslogtreecommitdiffstats
path: root/services/context
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-02 23:05:07 +0800
committerGitHub <noreply@github.com>2024-03-02 15:05:07 +0000
commit27deea7330f83ddb37c918afbb4159053d8847cb (patch)
treec55636fff59079106a013430076817f9a380f356 /services/context
parentcc27b50bdf9d1e2b02c91d7c4d338e01408e8522 (diff)
downloadgitea-27deea7330f83ddb37c918afbb4159053d8847cb.tar.gz
gitea-27deea7330f83ddb37c918afbb4159053d8847cb.zip
Make PR form use toast to show error message (#29545)
![image](https://github.com/go-gitea/gitea/assets/2114189/b7a14ed6-db89-4f21-a590-66cd33307233)
Diffstat (limited to 'services/context')
-rw-r--r--services/context/context_response.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/services/context/context_response.go b/services/context/context_response.go
index 829bca1f59..372b4cb38b 100644
--- a/services/context/context_response.go
+++ b/services/context/context_response.go
@@ -6,6 +6,7 @@ package context
import (
"errors"
"fmt"
+ "html/template"
"net"
"net/http"
"net/url"
@@ -104,11 +105,11 @@ func (ctx *Context) JSONTemplate(tmpl base.TplName) {
}
}
-// RenderToString renders the template content to a string
-func (ctx *Context) RenderToString(name base.TplName, data map[string]any) (string, error) {
+// RenderToHTML renders the template content to a HTML string
+func (ctx *Context) RenderToHTML(name base.TplName, data map[string]any) (template.HTML, error) {
var buf strings.Builder
- err := ctx.Render.HTML(&buf, http.StatusOK, string(name), data, ctx.TemplateContext)
- return buf.String(), err
+ err := ctx.Render.HTML(&buf, 0, string(name), data, ctx.TemplateContext)
+ return template.HTML(buf.String()), err
}
// RenderWithErr used for page has form validation but need to prompt error to users.