我正在尝试通过 iris golang web 框架中的一段结构,如下所示。
type prodcont struct{
List []Post
}
type Post struct{
Id int
Title string
Slug string
ShortDescription string
Content string
}
var Posts = []Post{
Post{content ommitted}
}
//GET categories
func IndexPost(c *iris.Context){
c.Render("admin/post/index.html", prodcont{Posts}, iris.RenderOptions{"gzip": true})
}
<table class="table table-striped table-bordered">
<thead>
<thead>
table head...
</thead>
</thead>
<tbody>
{{run range here}}
<tr>
<td>{{post.Id}}</td>
<td>{{post.Title}}</td>
<td>{{post.Slug}}</td>
<td>{{post.Shortdescription}}</td>
<td>{{post.Content}}</td>
</tr>
{{end}}
</tbody>
</table>
我试过了{{range .}}
,{{for _posts := range Posts}}
.etc 哪个没用?
这是我得到的错误
template: template/admin_template.html:61:7: executing "template/admin_template.html" at <yield>: error calling yield: html/template: "admin/post/index.html" is an incomplete template
在 Go Iris 框架中,我如何能够有效地通过上面所见的结构切片?谢谢