1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00

minor: fix Context.ViewData ignored when nil is passed as view data on Context.View method

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-30 16:14:32 +03:00
parent 600eb645df
commit 6ee69ffd1c
2 changed files with 17 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
app.Logger().SetLevel("debug")
// Init the handlebars engine
engine := iris.Handlebars("./templates", ".html").Reload(true)
@@ -27,6 +28,21 @@ func main() {
ctx.View("example.html", viewData)
})
/* See context-view-data example: Set data through one or more middleware
app.Get("/view_data", func(ctx iris.Context) {
ctx.ViewData("author", map[string]string{"firstName": "Jean", "lastName": "Valjean"})
ctx.ViewData("body", "Life is difficult")
ctx.ViewData("comments", []iris.Map{{
"author": map[string]string{"firstName": "Marcel", "lastName": "Beliveau"},
"body": "LOL!",
}})
ctx.Next()
}, func(ctx iris.Context) {
ctx.View("example.html")
})
*/
// Read more about its syntax at:
// https://github.com/aymerick/raymond and
// https://handlebarsjs.com/guide