1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00
Former-commit-id: 221e01638b671586cdab2b84518bd6a1c8d07bda
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-08-09 08:24:58 +03:00
parent eb29a80753
commit b7bc89335d
4 changed files with 119 additions and 33 deletions

View File

@@ -114,10 +114,27 @@ func main() {
ctx.View("todos/show.jet", todo)
})
app.Get("/all-done", func(ctx iris.Context) {
vars := make(view.JetRuntimeVars) // <-- or keep use the jet.VarMap, decision up to you, it refers to the same type.
vars.Set("showingAllDone", true)
view.AddJetRuntimeVars(ctx, vars) // <--
ctx.View("todos/index.jet", (&doneTODOs{}).New(todos))
// vars := make(view.JetRuntimeVars)
// vars.Set("showingAllDone", true)
// vars.Set("title", "Todos - All Done")
// view.AddJetRuntimeVars(ctx, vars)
// ctx.View("todos/index.jet", (&doneTODOs{}).New(todos))
//
// OR
ctx.ViewData("showingAllDone", true)
ctx.ViewData("title", "Todos - All Done")
// Key does not actual matters at all here.
// However, you can enable it for better performance.
// In order to enable key mapping for
// jet specific renderer and ranger types
// then initialize the View Engine
// by `tmpl.DisableViewDataTypeCheck("_jet")`.
//
// Defaults to type checks, empty key.
ctx.ViewData("_jet", (&doneTODOs{}).New(todos))
ctx.View("todos/index.jet")
})
port := os.Getenv("PORT")