MCPcopy Create free account
hub / github.com/kataras/iris / Hello

Function Hello

_examples/view/quicktemplate/controllers/hello.go:10–30  ·  view source on GitHub ↗

Hello renders our ../templates/hello.qtpl file using the compiled ../templates/hello.qtpl.go file.

(ctx iris.Context)

Source from the content-addressed store, hash-verified

8
9// Hello renders our ../templates/hello.qtpl file using the compiled ../templates/hello.qtpl.go file.
10func 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}

Callers

nothing calls this directly

Calls 5

ExecuteTemplateFunction · 0.85
ViewDataMethod · 0.80
ParamsMethod · 0.80
GetViewDataMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…