mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Make PR form use toast to show error message (#29545)

(cherry picked from commit 27deea7330f83ddb37c918afbb4159053d8847cb)
This commit is contained in:
parent
d509031e84
commit
221a28436a
7 changed files with 35 additions and 30 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue