mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
builtin html template functions changes
This commit is contained in:
parent
abeae40e60
commit
1ea5cd58be
|
@ -28,6 +28,8 @@ The codebase for Dependency Injection, Internationalization and localization and
|
||||||
|
|
||||||
## Fixes and Improvements
|
## Fixes and Improvements
|
||||||
|
|
||||||
|
- **Breaking-change**: HTML template functions `yield`, `part`, `partial`, `partial_r` and `render` now accept (and require for some cases) a second argument of the binding data context too. Convert: `{{ yield }}` to `{{ yield . }}`, `{{ render "templates/mytemplate.html" }}` to `{{ render "templates/mytemplate.html" . }}`, `{{ partial "partials/mypartial.html" }}` to `{{ partial "partials/mypartial.html" . }}` and so on.
|
||||||
|
|
||||||
- Add new `URLParamSeparator` to the configuration. Defaults to "," but can be set to an empty string to disable splitting query values on `Context.URLParamSlice` method.
|
- Add new `URLParamSeparator` to the configuration. Defaults to "," but can be set to an empty string to disable splitting query values on `Context.URLParamSlice` method.
|
||||||
|
|
||||||
- [PR #1992](https://github.com/kataras/iris/pull/1992): Added support for third party packages on [httptest](https://github.com/kataras/iris/tree/master/httptest). An example using 3rd-party module named [Ginkgo](github.com/onsi/ginkgo) can be found [here](https://github.com/kataras/iris/blob/master/_examples/testing/ginkgotest).
|
- [PR #1992](https://github.com/kataras/iris/pull/1992): Added support for third party packages on [httptest](https://github.com/kataras/iris/tree/master/httptest). An example using 3rd-party module named [Ginkgo](github.com/onsi/ginkgo) can be found [here](https://github.com/kataras/iris/blob/master/_examples/testing/ginkgotest).
|
||||||
|
|
|
@ -20,5 +20,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ html
|
||||||
head
|
head
|
||||||
title {{.Title}}
|
title {{.Title}}
|
||||||
body
|
body
|
||||||
{{ yield }}
|
{{ yield . . }}
|
||||||
footer
|
footer
|
||||||
= include partials/footer.ace .
|
= include partials/footer.ace .
|
||||||
|
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
// On Amber this is ignored: ctx.ViewLayout("layouts/main")
|
// On Amber this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html><head><title>{{.Title}}</title></head><body>{{ template "content" . }}<footer>{{ partial "partials/footer" .}}</footer></body></html>
|
<!DOCTYPE html><html><head><title>{{.Title}}</title></head><body>{{ template "content" . }}<footer>{{ partial "partials/footer" . }}</footer></body></html>
|
|
@ -21,5 +21,8 @@ func index(ctx iris.Context) {
|
||||||
// On Django this is ignored: ctx.ViewLayout("layouts/main")
|
// On Django this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html><head><title>{{Title}}</title></head><body>{{ yield }}<footer>{{ render "partials/footer.html" .}}</footer></body></html>
|
<!DOCTYPE html><html><head><title>{{Title}}</title></head><body>{{ yield . }}<footer>{{ render "partials/footer.html" .}}</footer></body></html>
|
|
@ -20,5 +20,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html><head><title>{{.Title}}</title></head><body>{{ yield }}<footer>{{ render "partials/footer.html" }}</footer></body></html>
|
<!DOCTYPE html><html><head><title>{{.Title}}</title></head><body>{{ yield . }}<footer>{{ render "partials/footer.html" . }}</footer></body></html>
|
|
@ -21,5 +21,8 @@ func index(ctx iris.Context) {
|
||||||
// On Jet this is ignored: ctx.ViewLayout("layouts/main")
|
// On Jet this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
// On Pug this is ignored: ctx.ViewLayout("layouts/main")
|
// On Pug this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderSigninForm(ctx iris.Context) {
|
func renderSigninForm(ctx iris.Context) {
|
||||||
ctx.View("signin", iris.Map{"Title": "Signin Page"})
|
if err := ctx.View("signin", iris.Map{"Title": "Signin Page"}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderMemberPage(s *auth.Auth[User]) iris.Handler {
|
func renderMemberPage(s *auth.Auth[User]) iris.Handler {
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main>{{ template "content" . }}</main>
|
<main>{{ template "content" . }}</main>
|
||||||
<footer style="position: fixed; bottom: 0; width: 100%;">{{ partial "partials/footer" .}}</footer>
|
<footer style="position: fixed; bottom: 0; width: 100%;">{{ partial "partials/footer" . }}</footer>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -377,9 +377,12 @@ func main() {
|
||||||
// ctx.View("user.html", user)
|
// ctx.View("user.html", user)
|
||||||
//
|
//
|
||||||
// Directly (user as .user variable):
|
// Directly (user as .user variable):
|
||||||
ctx.View("user.html", iris.Map{
|
if err := ctx.View("user.html", iris.Map{
|
||||||
"user": user,
|
"user": user,
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/logout/{provider}", func(ctx iris.Context) {
|
app.Get("/logout/{provider}", func(ctx iris.Context) {
|
||||||
|
@ -395,11 +398,17 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.View("user.html", gothUser)
|
if err := ctx.View("user.html", gothUser); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("index.html", providerIndex)
|
if err := ctx.View("index.html", providerIndex); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// http://localhost:3000
|
// http://localhost:3000
|
||||||
|
|
|
@ -42,5 +42,8 @@ func register(ctx iris.Context) {
|
||||||
|
|
||||||
func registerForm(ctx iris.Context) {
|
func registerForm(ctx iris.Context) {
|
||||||
ctx.ViewData("SiteKey", siteKey)
|
ctx.ViewData("SiteKey", siteKey)
|
||||||
ctx.View("register_form.html")
|
if err := ctx.View("register_form.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,10 @@ func (b *Bootstrapper) SetupErrorHandlers() {
|
||||||
|
|
||||||
ctx.ViewData("Err", err)
|
ctx.ViewData("Err", err)
|
||||||
ctx.ViewData("Title", "Error")
|
ctx.ViewData("Title", "Error")
|
||||||
ctx.View("shared/error.html")
|
if err := ctx.View("shared/error.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,8 @@ import (
|
||||||
// GetIndexHandler handles the GET: /
|
// GetIndexHandler handles the GET: /
|
||||||
func GetIndexHandler(ctx iris.Context) {
|
func GetIndexHandler(ctx iris.Context) {
|
||||||
ctx.ViewData("Title", "Index Page")
|
ctx.ViewData("Title", "Index Page")
|
||||||
ctx.View("index.html")
|
if err := ctx.View("index.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
<hr />
|
<hr />
|
||||||
<footer>
|
<footer>
|
||||||
<p>© 2017 - {{.AppOwner}}</p>
|
<p>© 2017 - {{.AppOwner}}</p>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -106,7 +106,10 @@ func main() {
|
||||||
// Render the actual form
|
// Render the actual form
|
||||||
// GET: http://localhost:8080
|
// GET: http://localhost:8080
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("upload.html")
|
if err := ctx.View("upload.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Upload the file to the server
|
// Upload the file to the server
|
||||||
|
|
|
@ -171,7 +171,10 @@ func main() {
|
||||||
app.HandleDir("/public", iris.Dir("./public"))
|
app.HandleDir("/public", iris.Dir("./public"))
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("upload.html")
|
if err := ctx.View("upload.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
files := scanUploads(uploadsDir)
|
files := scanUploads(uploadsDir)
|
||||||
|
|
|
@ -124,7 +124,10 @@ func main() {
|
||||||
app.HandleDir("/public", iris.Dir("./public"))
|
app.HandleDir("/public", iris.Dir("./public"))
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("upload.html")
|
if err := ctx.View("upload.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
files := scanUploads(uploadsDir)
|
files := scanUploads(uploadsDir)
|
||||||
|
|
|
@ -94,7 +94,10 @@ func uploadView(ctx iris.Context) {
|
||||||
io.WriteString(h, strconv.FormatInt(now, 10))
|
io.WriteString(h, strconv.FormatInt(now, 10))
|
||||||
token := fmt.Sprintf("%x", h.Sum(nil))
|
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) {
|
func upload(ctx iris.Context) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/x/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest
|
// $ 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) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.ViewData("Page", page)
|
ctx.ViewData("Page", page)
|
||||||
if err := ctx.View("index.html"); err != nil {
|
if err := ctx.View("index.html"); err != nil {
|
||||||
errors.InvalidArgument.Err(ctx, err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,6 +27,9 @@ func fullVueRouter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,7 +31,10 @@ func main() {
|
||||||
// ctx.ViewData("", token)
|
// ctx.ViewData("", token)
|
||||||
// or add second argument to the `View` method.
|
// or add second argument to the `View` method.
|
||||||
// Token will be passed as {{.}} in the template.
|
// 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.
|
/* Read before continue.
|
||||||
|
|
|
@ -32,7 +32,10 @@ func newApp() *iris.Application {
|
||||||
token := fmt.Sprintf("%x", h.Sum(nil))
|
token := fmt.Sprintf("%x", h.Sum(nil))
|
||||||
|
|
||||||
// render the form with the token for any use you'd like.
|
// 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.
|
// Handle the post request from the upload_form.html to the server.
|
||||||
|
|
|
@ -81,12 +81,15 @@ func newApp() *iris.Application {
|
||||||
app.RegisterView(view)
|
app.RegisterView(view)
|
||||||
|
|
||||||
app.Get("/templates", func(ctx iris.Context) {
|
app.Get("/templates", func(ctx iris.Context) {
|
||||||
ctx.View("index.html", iris.Map{
|
if err := ctx.View("index.html", iris.Map{
|
||||||
"tr": ctx.Tr, // word, arguments... {call .tr "hi" "iris"}}
|
"tr": ctx.Tr, // word, arguments... {call .tr "hi" "iris"}}
|
||||||
"trUnsafe": func(message string, args ...interface{}) template.HTML {
|
"trUnsafe": func(message string, args ...interface{}) template.HTML {
|
||||||
return template.HTML(ctx.Tr(message, args...))
|
return template.HTML(ctx.Tr(message, args...))
|
||||||
},
|
},
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Note that,
|
// Note that,
|
||||||
// Iris automatically adds a "tr" global template function as well,
|
// Iris automatically adds a "tr" global template function as well,
|
||||||
|
|
|
@ -49,9 +49,9 @@ func (e errorResponse) Dispatch(ctx iris.Context) {
|
||||||
// switch e.Code {
|
// switch e.Code {
|
||||||
// case iris.StatusNotFound:
|
// case iris.StatusNotFound:
|
||||||
// // use Code and Message as the template data.
|
// // use Code and Message as the template data.
|
||||||
// ctx.View("404.html", e)
|
// if err := ctx.View("404.html", e)
|
||||||
// default:
|
// default:
|
||||||
// ctx.View("500.html", e)
|
// if err := ctx.View("500.html", e)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -33,7 +33,10 @@ func main() {
|
||||||
app.OnAnyErrorCode(func(ctx iris.Context) {
|
app.OnAnyErrorCode(func(ctx iris.Context) {
|
||||||
ctx.ViewData("Message", ctx.Values().
|
ctx.ViewData("Message", ctx.Values().
|
||||||
GetStringDefault("message", "The page you're looking for doesn't exist"))
|
GetStringDefault("message", "The page you're looking for doesn't exist"))
|
||||||
ctx.View("shared/error.html")
|
if err := ctx.View("shared/error.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// ---- Serve our controllers. ----
|
// ---- Serve our controllers. ----
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -51,7 +51,10 @@ func newApp() *iris.Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderSigninForm(ctx iris.Context) {
|
func renderSigninForm(ctx iris.Context) {
|
||||||
ctx.View("signin", iris.Map{"Title": "Signin Page"})
|
if err := ctx.View("signin", iris.Map{"Title": "Signin Page"}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type websocketController struct {
|
type websocketController struct {
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<main>{{ template "content" . }}</main>
|
<main>{{ template "content" . }}</main>
|
||||||
<footer style="position: fixed; bottom: 0; width: 100%;">{{ partial "partials/footer" .}}</footer>
|
<footer style="position: fixed; bottom: 0; width: 100%;">{{ partial "partials/footer" . }}</footer>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -13,7 +13,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func showForm(ctx iris.Context) {
|
func showForm(ctx iris.Context) {
|
||||||
ctx.View("form.html")
|
if err := ctx.View("form.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type formExample struct {
|
type formExample struct {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func main() {
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
if err := ctx.View("form.html"); err != nil {
|
if err := ctx.View("form.html"); err != nil {
|
||||||
ctx.StopWithError(iris.StatusInternalServerError, err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -100,7 +100,10 @@ func profileByUsername(ctx iris.Context) {
|
||||||
ctx.ViewData("Username", username)
|
ctx.ViewData("Username", username)
|
||||||
// renders "./views/user/profile.html"
|
// renders "./views/user/profile.html"
|
||||||
// with {{ .Username }} equals to the username dynamic path parameter.
|
// with {{ .Username }} equals to the username dynamic path parameter.
|
||||||
ctx.View("user/profile.html")
|
if err := ctx.View("user/profile.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserByID(ctx iris.Context) {
|
func getUserByID(ctx iris.Context) {
|
||||||
|
@ -122,5 +125,8 @@ func createUser(ctx iris.Context) {
|
||||||
// renders "./views/user/create_verification.html"
|
// renders "./views/user/create_verification.html"
|
||||||
// with {{ . }} equals to the User object, i.e {{ .Username }} , {{ .Firstname}} etc...
|
// with {{ . }} equals to the User object, i.e {{ .Username }} , {{ .Firstname}} etc...
|
||||||
ctx.ViewData("", user)
|
ctx.ViewData("", user)
|
||||||
ctx.View("user/create_verification.html")
|
if err := ctx.View("user/create_verification.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,12 @@ func newApp() *iris.Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleNotFoundTestSubdomain(ctx iris.Context) {
|
func handleNotFoundTestSubdomain(ctx iris.Context) {
|
||||||
ctx.View("error.html", iris.Map{
|
if err := ctx.View("error.html", iris.Map{
|
||||||
"ErrorCode": ctx.GetStatusCode(),
|
"ErrorCode": ctx.GetStatusCode(),
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testIndex(ctx iris.Context) {
|
func testIndex(ctx iris.Context) {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<h1>Oups, you've got an error!</h1>
|
<h1>Oups, you've got an error!</h1>
|
||||||
{{ if .ErrorCode }}
|
{{ if .ErrorCode }}
|
||||||
{{ $tmplName := print "partials/" .ErrorCode ".html"}}
|
{{ $tmplName := print "partials/" .ErrorCode ".html"}}
|
||||||
{{ render $tmplName }}
|
{{ render $tmplName . }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ render "partials/500.html" }}
|
{{ render "partials/500.html" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the global layout</h1>
|
<h1>This is the global layout</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -98,5 +98,8 @@ func testError(v string) iris.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testView(ctx iris.Context) {
|
func testView(ctx iris.Context) {
|
||||||
ctx.View("index.html")
|
if err := ctx.View("index.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,17 @@ func setSessionViewData(ctx iris.Context) {
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
session := sessions.Get(ctx)
|
session := sessions.Get(ctx)
|
||||||
session.Set("username", "kataras")
|
session.Set("username", "kataras")
|
||||||
ctx.View("index")
|
if err := ctx.View("index"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
/* OR without middleware:
|
/* OR without middleware:
|
||||||
ctx.View("index", iris.Map{
|
if err := ctx.View("index", iris.Map{
|
||||||
"session": session,
|
"session": session,
|
||||||
// {{.session.Get "username"}}
|
// {{.session.Get "username"}}
|
||||||
// OR to pass only the 'username':
|
// OR to pass only the 'username':
|
||||||
// "username": session.Get("username"),
|
// "username": session.Get("username"),
|
||||||
// {{.username}}
|
// {{.username}}
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,10 @@ func newApp(db *DB) *iris.Application {
|
||||||
|
|
||||||
indexHandler := func(ctx iris.Context) {
|
indexHandler := func(ctx iris.Context) {
|
||||||
ctx.ViewData("URL_COUNT", db.Len())
|
ctx.ViewData("URL_COUNT", db.Len())
|
||||||
ctx.View("index.html")
|
if err := ctx.View("index.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
app.Get("/", indexHandler)
|
app.Get("/", indexHandler)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -37,7 +37,10 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func admin(ctx iris.Context) {
|
func admin(ctx iris.Context) {
|
||||||
|
@ -46,7 +49,10 @@ func admin(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setViews(views iris.ViewEngine) iris.Handler {
|
func setViews(views iris.ViewEngine) iris.Handler {
|
||||||
|
@ -61,5 +67,8 @@ func onFly(ctx iris.Context) {
|
||||||
"Message": "View engine changed through 'setViews' custom middleware.",
|
"Message": "View engine changed through 'setViews' custom middleware.",
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
<body>
|
<body>
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
|
|
||||||
<footer>{{ partial "partials/footer" .}}</footer>
|
<footer>{{ partial "partials/footer" . }}</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -37,10 +37,16 @@ func main() {
|
||||||
my := app.Party("/my").Layout("layouts/mylayout.html")
|
my := app.Party("/my").Layout("layouts/mylayout.html")
|
||||||
{ // both of these will use the layouts/mylayout.html as their layout.
|
{ // both of these will use the layouts/mylayout.html as their layout.
|
||||||
my.Get("/", func(ctx iris.Context) {
|
my.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
my.Get("/other", func(ctx iris.Context) {
|
my.Get("/other", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the global layout</h1>
|
<h1>This is the global layout</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
||||||
|
|
||||||
{{ render "partials/page1_partial1.html"}}
|
{{ render "partials/page1_partial1.html" . }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the global layout</h1>
|
<h1>This is the global layout</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
||||||
|
|
||||||
{{ render "partials/page1_partial1.html"}}
|
{{ render "partials/page1_partial1.html" . }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/x/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed embedded/*
|
//go:embed embedded/*
|
||||||
|
@ -24,7 +23,7 @@ func main() {
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
if err := ctx.View("page1.html"); err != nil {
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
errors.InvalidArgument.Err(ctx, err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -33,7 +32,7 @@ func main() {
|
||||||
app.Get("/nolayout", func(ctx iris.Context) {
|
app.Get("/nolayout", func(ctx iris.Context) {
|
||||||
ctx.ViewLayout(iris.NoLayout)
|
ctx.ViewLayout(iris.NoLayout)
|
||||||
if err := ctx.View("page1.html"); err != nil {
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
errors.InvalidArgument.Err(ctx, err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -42,10 +41,16 @@ func main() {
|
||||||
my := app.Party("/my").Layout("layouts/mylayout.html")
|
my := app.Party("/my").Layout("layouts/mylayout.html")
|
||||||
{ // both of these will use the layouts/mylayout.html as their layout.
|
{ // both of these will use the layouts/mylayout.html as their layout.
|
||||||
my.Get("/", func(ctx iris.Context) {
|
my.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
my.Get("/other", func(ctx iris.Context) {
|
my.Get("/other", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,5 +38,8 @@ func main() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("blabla.html")
|
if err := ctx.View("blabla.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ html
|
||||||
head
|
head
|
||||||
title {{.Title}}
|
title {{.Title}}
|
||||||
body
|
body
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
footer
|
footer
|
||||||
= include partials/footer.ace .
|
= include partials/footer.ace .
|
|
@ -21,5 +21,8 @@ func index(ctx iris.Context) {
|
||||||
// On Amber this is ignored: ctx.ViewLayout("layouts/main")
|
// On Amber this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<body>
|
<body>
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
<footer>
|
<footer>
|
||||||
{{ partial "partials/footer" .}}
|
{{ partial "partials/footer" . }}
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -21,5 +21,8 @@ func index(ctx iris.Context) {
|
||||||
// On Django this is ignored: ctx.ViewLayout("layouts/main")
|
// On Django this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,5 +20,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<title>{{Title}}</title>
|
<title>{{Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
|
|
||||||
<footer>{{ render "partials/footer.html" .}}</footer>
|
<footer>{{ render "partials/footer.html" .}}</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -20,5 +20,8 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("layouts/main")
|
ctx.ViewLayout("layouts/main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
<footer>
|
<footer>
|
||||||
{{ render "partials/footer.html" }}
|
{{ render "partials/footer.html" . }}
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -22,5 +22,8 @@ func index(ctx iris.Context) {
|
||||||
// On Jet this is ignored: ctx.ViewLayout("layouts/main")
|
// On Jet this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{ yield documentBody() }}
|
{{ yield . documentBody() }}
|
||||||
<footer>{{ include "../partials/footer.jet" . }}</footer>
|
<footer>{{ include "../partials/footer.jet" . }}</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -21,5 +21,8 @@ func index(ctx iris.Context) {
|
||||||
// On Pug this is ignored: ctx.ViewLayout("layouts/main")
|
// On Pug this is ignored: ctx.ViewLayout("layouts/main")
|
||||||
// Layouts are only rendered from inside the index page itself
|
// Layouts are only rendered from inside the index page itself
|
||||||
// using the "extends" keyword.
|
// using the "extends" keyword.
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ func main() {
|
||||||
// with default template funcs:
|
// with default template funcs:
|
||||||
//
|
//
|
||||||
// - {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
|
// - {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
|
||||||
// - {{ render "header.html" }}
|
// - {{ render "header.html" . }}
|
||||||
// - {{ render_r "header.html" }} // partial relative path to current page
|
// - {{ render_r "header.html" . }} // partial relative path to current page
|
||||||
// - {{ yield }}
|
// - {{ yield . }}
|
||||||
// - {{ current }}
|
// - {{ current . }}
|
||||||
app.RegisterView(iris.HTML("./templates", ".html").
|
app.RegisterView(iris.HTML("./templates", ".html").
|
||||||
Reload(true)) // Set Reload false to production.
|
Reload(true)) // Set Reload false to production.
|
||||||
|
|
||||||
|
@ -23,17 +23,23 @@ func main() {
|
||||||
ctx.ViewData("Name", "iris")
|
ctx.ViewData("Name", "iris")
|
||||||
// render the template with the file name relative to the './templates'.
|
// render the template with the file name relative to the './templates'.
|
||||||
// file extension is OPTIONAL.
|
// file extension is OPTIONAL.
|
||||||
ctx.View("hi.html")
|
if err := ctx.View("hi.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/example_map", func(ctx iris.Context) {
|
app.Get("/example_map", func(ctx iris.Context) {
|
||||||
ctx.View("example.html", iris.Map{
|
if err := ctx.View("example.html", iris.Map{
|
||||||
"Name": "Example Name",
|
"Name": "Example Name",
|
||||||
"Age": 42,
|
"Age": 42,
|
||||||
"Items": []string{"Example slice entry 1", "entry 2", "entry 3"},
|
"Items": []string{"Example slice entry 1", "entry 2", "entry 3"},
|
||||||
"Map": iris.Map{"map key": "map value", "other key": "other value"},
|
"Map": iris.Map{"map key": "map value", "other key": "other value"},
|
||||||
"Nested": iris.Map{"Title": "Iris E-Book", "Pages": 620},
|
"Nested": iris.Map{"Title": "Iris E-Book", "Pages": 620},
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/example_struct", func(ctx iris.Context) {
|
app.Get("/example_struct", func(ctx iris.Context) {
|
||||||
|
@ -59,7 +65,10 @@ func main() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.View("example.html", examplePage)
|
if err := ctx.View("example.html", examplePage); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// http://localhost:8080/
|
// http://localhost:8080/
|
||||||
|
|
|
@ -21,9 +21,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("program.amber", iris.Map{
|
if err := ctx.View("program.amber", iris.Map{
|
||||||
"Name": "Gerasimos",
|
"Name": "Gerasimos",
|
||||||
// Or per template:
|
// Or per template:
|
||||||
// "greet": func(....)
|
// "greet": func(....)
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("program.html", iris.Map{
|
if err := ctx.View("program.html", iris.Map{
|
||||||
"Name": "Gerasimos",
|
"Name": "Gerasimos",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("program.html", iris.Map{
|
if err := ctx.View("program.html", iris.Map{
|
||||||
"Name": "Gerasimos",
|
"Name": "Gerasimos",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("program.jet", iris.Map{
|
if err := ctx.View("program.jet", iris.Map{
|
||||||
"Name": "Gerasimos",
|
"Name": "Gerasimos",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(ctx iris.Context) {
|
func index(ctx iris.Context) {
|
||||||
ctx.View("program.html", iris.Map{
|
if err := ctx.View("program.html", iris.Map{
|
||||||
"Name": "Gerasimos",
|
"Name": "Gerasimos",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func layout(ctx iris.Context) {
|
func layout(ctx iris.Context) {
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>[layout] Body content is below...</h1>
|
<h1>[layout] Body content is below...</h1>
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -12,16 +12,22 @@ func main() {
|
||||||
app.RegisterView(tmpl)
|
app.RegisterView(tmpl)
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("index", iris.Map{
|
if err := ctx.View("index", iris.Map{
|
||||||
"Title": "Title of The Page",
|
"Title": "Title of The Page",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/layout", func(ctx iris.Context) {
|
app.Get("/layout", func(ctx iris.Context) {
|
||||||
ctx.ViewLayout("layouts/main") // layout for that response.
|
ctx.ViewLayout("layouts/main") // layout for that response.
|
||||||
ctx.View("index", iris.Map{ // file extension is optional.
|
if err := ctx.View("index", iris.Map{ // file extension is optional.
|
||||||
"Title": "Title of the main Page",
|
"Title": "Title of the main Page",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// otherGroup := app.Party("/other").Layout("layouts/other.ace") -> layout for that party.
|
// otherGroup := app.Party("/other").Layout("layouts/other.ace") -> layout for that party.
|
||||||
|
|
|
@ -4,4 +4,4 @@ html
|
||||||
title Main Page
|
title Main Page
|
||||||
body
|
body
|
||||||
h1 Layout
|
h1 Layout
|
||||||
{{ yield }}
|
{{ yield . }}
|
|
@ -11,9 +11,12 @@ func main() {
|
||||||
app.RegisterView(tmpl)
|
app.RegisterView(tmpl)
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("index.amber", iris.Map{
|
if err := ctx.View("index.amber", iris.Map{
|
||||||
"Title": "Title of The Page",
|
"Title": "Title of The Page",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Listen(":8080")
|
app.Listen(":8080")
|
||||||
|
|
|
@ -19,9 +19,12 @@ func main() {
|
||||||
app.RegisterView(tmpl)
|
app.RegisterView(tmpl)
|
||||||
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("index.amber", iris.Map{
|
if err := ctx.View("index.amber", iris.Map{
|
||||||
"Title": "Title of The Page",
|
"Title": "Title of The Page",
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Listen(":8080")
|
app.Listen(":8080")
|
||||||
|
|
|
@ -19,7 +19,10 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func internalServerError(ctx iris.Context) {
|
func internalServerError(ctx iris.Context) {
|
||||||
|
@ -31,5 +34,8 @@ func internalServerError(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("error")
|
ctx.ViewLayout("error")
|
||||||
ctx.View("500", data)
|
if err := ctx.View("500", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
<body>
|
<body>
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
|
|
||||||
<footer>{{ partial "partials/footer" .}}</footer>
|
<footer>{{ partial "partials/footer" . }}</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -28,7 +28,10 @@ func index(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("main")
|
ctx.ViewLayout("main")
|
||||||
ctx.View("index", data)
|
if err := ctx.View("index", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func internalServerError(ctx iris.Context) {
|
func internalServerError(ctx iris.Context) {
|
||||||
|
@ -40,5 +43,8 @@ func internalServerError(ctx iris.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewLayout("error")
|
ctx.ViewLayout("error")
|
||||||
ctx.View("500", data)
|
if err := ctx.View("500", data); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,12 @@ func hi(ctx iris.Context) {
|
||||||
// or if you set all view data in the same handler you can use the
|
// or if you set all view data in the same handler you can use the
|
||||||
// iris.Map/pongo2.Context/map[string]interface{}, look below:
|
// iris.Map/pongo2.Context/map[string]interface{}, look below:
|
||||||
|
|
||||||
ctx.View("hi.html", iris.Map{
|
if err := ctx.View("hi.html", iris.Map{
|
||||||
"title": "Hi Page",
|
"title": "Hi Page",
|
||||||
"name": "iris",
|
"name": "iris",
|
||||||
"serverStartTime": startTime,
|
"serverStartTime": startTime,
|
||||||
})
|
}); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ func main() {
|
||||||
paramsAsArray := []string{"theParam1", "theParam2", "paramThirdAfterStatic"}
|
paramsAsArray := []string{"theParam1", "theParam2", "paramThirdAfterStatic"}
|
||||||
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
||||||
if err := ctx.View("page.html"); err != nil {
|
if err := ctx.View("page.html"); err != nil {
|
||||||
panic(err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,10 @@ func main() {
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.View("example.html", viewData)
|
if err := ctx.View("example.html", viewData); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
exampleRouter := app.Party("/example")
|
exampleRouter := app.Party("/example")
|
||||||
|
|
|
@ -12,10 +12,10 @@ func main() {
|
||||||
// default template funcs are:
|
// default template funcs are:
|
||||||
//
|
//
|
||||||
// - {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
|
// - {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
|
||||||
// - {{ render "header.html" }}
|
// - {{ render "header.html" . }}
|
||||||
// - {{ render_r "header.html" }} // partial relative path to current page
|
// - {{ render_r "header.html" . }} // partial relative path to current page
|
||||||
// - {{ yield }}
|
// - {{ yield . }}
|
||||||
// - {{ current }}
|
// - {{ current . }}
|
||||||
tmpl.AddFunc("greet", func(s string) string {
|
tmpl.AddFunc("greet", func(s string) string {
|
||||||
return "Greetings " + s + "!"
|
return "Greetings " + s + "!"
|
||||||
})
|
})
|
||||||
|
@ -31,5 +31,8 @@ func hi(ctx iris.Context) {
|
||||||
ctx.ViewData("Title", "Hi Page")
|
ctx.ViewData("Title", "Hi Page")
|
||||||
ctx.ViewData("Name", "iris") // {{.Name}} will render: iris
|
ctx.ViewData("Name", "iris") // {{.Name}} will render: iris
|
||||||
// ctx.ViewData("", myCcustomStruct{})
|
// ctx.ViewData("", myCcustomStruct{})
|
||||||
ctx.View("hi.html")
|
if err := ctx.View("hi.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,10 @@ func main() {
|
||||||
app.Get("/", func(ctx iris.Context) {
|
app.Get("/", func(ctx iris.Context) {
|
||||||
ctx.CompressWriter(true)
|
ctx.CompressWriter(true)
|
||||||
ctx.ViewData("", mypage{"My Page title", "Hello world!"})
|
ctx.ViewData("", mypage{"My Page title", "Hello world!"})
|
||||||
ctx.View("mypage.html")
|
if err := ctx.View("mypage.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
|
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
|
||||||
// or view.NoLayout to disable layout on this render action.
|
// or view.NoLayout to disable layout on this render action.
|
||||||
// third is an optional parameter
|
// third is an optional parameter
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>[layout] Body content is below...</h1>
|
<h1>[layout] Body content is below...</h1>
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -35,10 +35,16 @@ func main() {
|
||||||
my := app.Party("/my").Layout("layouts/mylayout.html")
|
my := app.Party("/my").Layout("layouts/mylayout.html")
|
||||||
{ // both of these will use the layouts/mylayout.html as their layout.
|
{ // both of these will use the layouts/mylayout.html as their layout.
|
||||||
my.Get("/", func(ctx iris.Context) {
|
my.Get("/", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
my.Get("/other", func(ctx iris.Context) {
|
my.Get("/other", func(ctx iris.Context) {
|
||||||
ctx.View("page1.html")
|
if err := ctx.View("page1.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the global layout</h1>
|
<h1>This is the global layout</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
<h1>This is the layout for the /my/ and /my/other routes only</h1>
|
||||||
<br />
|
<br />
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
<h1>Page 1 {{ greet "iris developer"}}</h1>
|
||||||
|
|
||||||
{{ render "partials/page1_partial1.html" }}
|
{{ render "partials/page1_partial1.html" . }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -35,7 +35,8 @@ func main() {
|
||||||
paramsAsArray := []string{"theParam1", "theParam2", "paramThirdAfterStatic"}
|
paramsAsArray := []string{"theParam1", "theParam2", "paramThirdAfterStatic"}
|
||||||
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
||||||
if err := ctx.View("page.html"); err != nil {
|
if err := ctx.View("page.html"); err != nil {
|
||||||
panic(err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ func main() {
|
||||||
paramsAsArray := []string{"username5", "theParam1", "theParam2", "paramThirdAfterStatic"}
|
paramsAsArray := []string{"username5", "theParam1", "theParam2", "paramThirdAfterStatic"}
|
||||||
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
ctx.ViewData("ParamsAsArray", paramsAsArray)
|
||||||
if err := ctx.View("page.html"); err != nil {
|
if err := ctx.View("page.html"); err != nil {
|
||||||
panic(err)
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,28 @@ func main() {
|
||||||
|
|
||||||
app.Get("/home", func(ctx iris.Context) {
|
app.Get("/home", func(ctx iris.Context) {
|
||||||
ctx.ViewData("title", "Home page")
|
ctx.ViewData("title", "Home page")
|
||||||
ctx.View("home.html")
|
if err := ctx.View("home.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
|
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
|
||||||
// or view.NoLayout to disable layout on this render action.
|
// or view.NoLayout to disable layout on this render action.
|
||||||
// third is an optional parameter
|
// third is an optional parameter
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/about", func(ctx iris.Context) {
|
app.Get("/about", func(ctx iris.Context) {
|
||||||
ctx.View("about.html")
|
if err := ctx.View("about.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/user/index", func(ctx iris.Context) {
|
app.Get("/user/index", func(ctx iris.Context) {
|
||||||
ctx.View("user/index.html")
|
if err := ctx.View("user/index.html"); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// http://localhost:8080
|
// http://localhost:8080
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{ part "head" }}
|
{{ part "head"}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>[layout] Body content is below...</h1>
|
<h1>[layout] Body content is below...</h1>
|
||||||
{{ part "body" }}
|
{{ part "body" . }}
|
||||||
<!-- Render the current template here -->
|
<!-- Render the current template here -->
|
||||||
{{ yield }}
|
{{ yield . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -113,7 +113,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ViewData("title", "Show TODO")
|
ctx.ViewData("title", "Show TODO")
|
||||||
ctx.View("todos/show.jet", todo)
|
if err := ctx.View("todos/show.jet", todo); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
app.Get("/all-done", func(ctx iris.Context) {
|
app.Get("/all-done", func(ctx iris.Context) {
|
||||||
// vars := make(view.JetRuntimeVars)
|
// vars := make(view.JetRuntimeVars)
|
||||||
|
@ -132,7 +135,10 @@ func main() {
|
||||||
// ctx.ViewData("_jet", (&doneTODOs{}).New(todos))
|
// ctx.ViewData("_jet", (&doneTODOs{}).New(todos))
|
||||||
// and ctx.View("todos/index.jet")
|
// and ctx.View("todos/index.jet")
|
||||||
// OR
|
// OR
|
||||||
ctx.View("todos/index.jet", (&doneTODOs{}).New(todos))
|
if err := ctx.View("todos/index.jet", (&doneTODOs{}).New(todos)); err != nil {
|
||||||
|
ctx.HTML("<h3>%s</h3>", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user