本文整理汇总了Golang中github.com/unrolled/render.Render.HTML方法的典型用法代码示例。如果您正苦于以下问题:Golang Render.HTML方法的具体用法?Golang Render.HTML怎么用?Golang Render.HTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/unrolled/render.Render
的用法示例。
在下文中一共展示了Render.HTML方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TorrentHandler
// TorrentHandler is now commented
func TorrentHandler(w http.ResponseWriter, req *http.Request, renderer *render.Render) {
searchString := req.FormValue("search")
log.Printf("Searching for %s", searchString)
torrents := make(map[int][]string)
torrents = SearchTorrentsFor(searchString, torrents)
// prepare response page
renderer.HTML(w, http.StatusOK, "content", torrents)
}
示例2: ListDownloadsHandler
// ListDownloadsHandler AJAX method is now commented
func ListDownloadsHandler(w http.ResponseWriter, req *http.Request, renderer *render.Render) {
dir := req.FormValue("dir")
if strings.HasPrefix(dir, "~") {
homedir := os.Getenv("HOME")
dir = homedir + dir[1:]
}
files := structures.PrepareDirectoryContents(dir)
renderer.HTML(w, http.StatusOK, "downloadDirectory", files)
}
示例3: homeHandler
func homeHandler(renderer *render.Render, data HomeDisplay) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
renderer.HTML(w, http.StatusOK, "home-template", data)
})
}