Hello renders our ../templates/hello.qtpl file using the compiled ../templates/hello.qtpl.go file.
(ctx iris.Context)
| 8 | |
| 9 | // Hello renders our ../templates/hello.qtpl file using the compiled ../templates/hello.qtpl.go file. |
| 10 | func Hello(ctx iris.Context) { |
| 11 | // vars := make(map[string]interface{}) |
| 12 | // vars["message"] = "Hello World!" |
| 13 | // vars["name"] = ctx.Params().Get("name") |
| 14 | // [...] |
| 15 | // &templates.Hello{ Vars: vars } |
| 16 | // [...] |
| 17 | |
| 18 | // However, as an alternative, we recommend that you should the `ctx.ViewData(key, value)` |
| 19 | // in order to be able modify the `templates.Hello#Vars` from a middleware(other handlers) as well. |
| 20 | ctx.ViewData("message", "Hello World!") |
| 21 | ctx.ViewData("name", ctx.Params().Get("name")) |
| 22 | |
| 23 | // set view data to the `Vars` template's field |
| 24 | tmpl := &templates.Hello{ |
| 25 | Vars: ctx.GetViewData(), |
| 26 | } |
| 27 | |
| 28 | // render the template |
| 29 | ExecuteTemplate(ctx, tmpl) |
| 30 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…