mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 20:41:57 +00:00
minor: godoc
This commit is contained in:
@@ -27,24 +27,35 @@ func main() {
|
||||
|
||||
app.Get("/example_map", func(ctx iris.Context) {
|
||||
ctx.View("example.html", iris.Map{
|
||||
"Name": "Example Name",
|
||||
"Age": 42,
|
||||
"Items": []string{"Example slice entry 1", "entry 2", "entry 3"},
|
||||
"Map": iris.Map{"map key": "map value", "other key": "other value"},
|
||||
"Name": "Example Name",
|
||||
"Age": 42,
|
||||
"Items": []string{"Example slice entry 1", "entry 2", "entry 3"},
|
||||
"Map": iris.Map{"map key": "map value", "other key": "other value"},
|
||||
"Nested": iris.Map{"Title": "Iris E-Book", "Pages": 620},
|
||||
})
|
||||
})
|
||||
|
||||
app.Get("/example_struct", func(ctx iris.Context) {
|
||||
type book struct {
|
||||
Title string
|
||||
Pages int
|
||||
}
|
||||
|
||||
var examplePage = struct {
|
||||
Name string
|
||||
Age int
|
||||
Items []string
|
||||
Map map[string]interface{}
|
||||
Name string
|
||||
Age int
|
||||
Items []string
|
||||
Map map[string]interface{}
|
||||
Nested book
|
||||
}{
|
||||
"Example Name",
|
||||
42,
|
||||
[]string{"Example slice entry 1", "entry 2", "entry 3"},
|
||||
iris.Map{"map key": "map value", "other key": "other value"},
|
||||
book{
|
||||
"Iris E-Book",
|
||||
620,
|
||||
},
|
||||
}
|
||||
|
||||
ctx.View("example.html", examplePage)
|
||||
|
||||
@@ -6,18 +6,23 @@
|
||||
<title>HTML Template Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>{{.Name}}</h2>
|
||||
<h3>{{.Age}}</h3>
|
||||
<h2>Name: {{.Name}}</h2>
|
||||
<h3>Age: {{.Age}}</h3>
|
||||
|
||||
<h4>Slice</h4>
|
||||
{{range $idx, $item := .Items}}
|
||||
{{ $idx }} - {{ $item }} <br/>
|
||||
{{end}}
|
||||
|
||||
<h4>Map</h4>
|
||||
{{range $key, $value := .Map}}
|
||||
{{ $key }} - {{ $value }} <br/>
|
||||
{{end}}
|
||||
|
||||
<h4>Nested</h4>
|
||||
|
||||
<strong>Title:</strong>{{ .Nested.Title}}
|
||||
|
||||
<hr/>
|
||||
|
||||
<strong>Read more at: <a href="https://golang.org/pkg/html/template" target="_new">
|
||||
|
||||
Reference in New Issue
Block a user