1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-27 06:47:08 +00:00

builtin html template functions changes

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-12-13 01:37:15 +02:00
parent abeae40e60
commit 1ea5cd58be
115 changed files with 472 additions and 230 deletions

View File

@@ -94,7 +94,10 @@ func uploadView(ctx iris.Context) {
io.WriteString(h, strconv.FormatInt(now, 10))
token := fmt.Sprintf("%x", h.Sum(nil))
ctx.View("upload.html", token)
if err := ctx.View("upload.html", token); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
}
func upload(ctx iris.Context) {

View File

@@ -2,7 +2,6 @@ package main
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/x/errors"
)
// $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest
@@ -28,7 +27,7 @@ func newApp() *iris.Application {
app.Get("/", func(ctx iris.Context) {
ctx.ViewData("Page", page)
if err := ctx.View("index.html"); err != nil {
errors.InvalidArgument.Err(ctx, err)
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
})

View File

@@ -27,6 +27,9 @@ func fullVueRouter() {
}
func index(ctx iris.Context) {
ctx.View("index.html")
if err := ctx.View("index.html"); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
}
*/

View File

@@ -31,7 +31,10 @@ func main() {
// ctx.ViewData("", token)
// or add second argument to the `View` method.
// Token will be passed as {{.}} in the template.
ctx.View("upload_form.html", token)
if err := ctx.View("upload_form.html", token); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
})
/* Read before continue.

View File

@@ -32,7 +32,10 @@ func newApp() *iris.Application {
token := fmt.Sprintf("%x", h.Sum(nil))
// render the form with the token for any use you'd like.
ctx.View("upload_form.html", token)
if err := ctx.View("upload_form.html", token); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
})
// Handle the post request from the upload_form.html to the server.