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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user