本文整理匯總了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)
})
}