コード例 #1
0
func GetHomePage(rw http.ResponseWriter, req *http.Request) {
	type Page struct {
		Title string
	}

	p := Page{
		Title: "user_home",
	}

	common.Templates = template.Must(template.ParseFiles("templates/user/home.html", common.LayoutPath))
	err := common.Templates.ExecuteTemplate(rw, "base", p)
	common.CheckError(err, 2)
}
コード例 #2
0
func GetViewPage(rw http.ResponseWriter, req *http.Request) {
	type Page struct {
		Title  string
		UserId string
	}

	params := mux.Vars(req)
	userId := params["id"]

	p := Page{
		Title:  "user_view",
		UserId: userId,
	}

	common.Templates = template.Must(template.ParseFiles("templates/user/view.html", common.LayoutPath))
	err := common.Templates.ExecuteTemplate(rw, "base", p)
	common.CheckError(err, 2)
}