本文整理汇总了Golang中github.com/martini-contrib/render.Render.HTML方法的典型用法代码示例。如果您正苦于以下问题:Golang Render.HTML方法的具体用法?Golang Render.HTML怎么用?Golang Render.HTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/martini-contrib/render.Render
的用法示例。
在下文中一共展示了Render.HTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SectionsNew
// SectionsNew renders page for adding new CV section
func SectionsNew(r render.Render, tokens oauth2.Tokens, session sessions.Session, params martini.Params) {
pd := NewPageData(tokens, session)
sectionType, _ := strconv.Atoi(params["type"])
pd.SectionType = sectionType
pd.Section = &Section{}
r.HTML(200, "sections-new", pd)
}
示例2: GoLoginHandler
func GoLoginHandler(r render.Render, params martini.Params) {
path := params["path"]
if path == "" {
path = "/"
}
r.HTML(200, "admin/login", map[string]string{"path": path})
}
示例3: getLoginPage
func getLoginPage(user sessionauth.User, r render.Render) {
if user.IsAuthenticated() {
r.Redirect(INDEX_PAGE)
return
}
r.HTML(200, LOGIN_PAGE, nil)
}
示例4: Create
func (ps ProjectService) Create(projet models.Project, r render.Render) {
err := utils.ORM.Save(&projet).Error
if err != nil {
utils.Log.Error("Failed to create project: %v", err)
r.HTML(403, "project/new", projet)
}
}
示例5: recovery
func recovery(
c martini.Context,
req *http.Request,
ren render.Render,
dec formDecoder,
) {
defer func() {
if r := recover(); r != nil {
switch err := r.(type) {
case jsonError:
handleJsonError(err, ren)
case authError:
authenticate(err, dec, ren, req)
case userError:
ren.HTML(200, "error", m{
"Message": formatMessage(err.Error()),
})
case csql.Error:
ren.HTML(200, "error", m{
"Message": formatMessage(err.Error()),
})
default:
panic(r)
}
}
}()
c.Next()
}
示例6: Edit
func Edit(params martini.Params, r render.Render, db *mgo.Database) {
available := new(AvailableForm)
available.Op = "Edit"
available.Channels = append(available.Channels,
Channel{"email", false},
Channel{"web", false},
Channel{"push", false},
)
oId := bson.ObjectIdHex(params["_id"])
err := db.C(availableCollection).FindId(oId).One(&available.Topic)
if err != nil {
r.HTML(400, "400", err)
}
fmt.Println(available.Channels)
for i, v := range available.Channels {
for _, value := range available.Topic.Channels {
if v.Name == value {
available.Channels[i].Enabled = true
}
}
}
r.HTML(200, "available/form", available)
}
示例7: SignUp
func SignUp(s sessions.Session, r render.Render, x csrf.CSRF) {
returnvals := map[string]interface{}{
"csrf": x.GetToken(),
"Title": "Nightcrawler Signup",
}
r.HTML(200, "sign_up", returnvals)
}
示例8: GetPaste
func GetPaste(params martini.Params, ren render.Render, r *http.Request, cf *swift.Connection, mc *memcache.Client) {
cachedPaste, err := mc.Get(params["pasteid"])
format := params["format"]
if err != nil {
log.Println(err)
}
var paste Paste
paste.PasteId = params["pasteid"]
if cachedPaste == nil {
log.Println("Asking swift for ", params["pasteid"])
cfPaste, err := cf.ObjectGetBytes("go-cfpaste", params["pasteid"])
if err != nil {
if err.Error() == "Object Not Found" {
ren.HTML(404, "404", paste)
return
} else {
log.Println(err)
ren.Error(500)
return
}
}
err = json.Unmarshal(cfPaste, &paste)
PanicIf(err)
} else {
log.Println("Cache hit for ", params["pasteid"])
err = json.Unmarshal(cachedPaste.Value, &paste)
PanicIf(err)
}
if format == "json" {
ren.JSON(200, paste)
} else {
ren.HTML(200, "paste", paste)
}
return
}
示例9: EditComponent
func EditComponent(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) {
var component_id string = params["id"]
if component_id != "new" {
component, err := repository.GetComponent(db, component_id)
if err != nil || component == nil {
t.SessionMessage.AddDanger("Failed to load component.")
ren.Redirect("/component")
return
}
t.Data = component
id, _ := strconv.ParseInt(params["id"], 10, 64)
t.MediaList = getMediaList(db, COMPONENT, id)
ren.HTML(200, "blah/component/edit", t)
} else {
ren.HTML(200, "blah/component/edit", nil)
}
}
示例10: SearchPage
func SearchPage(user common.User, session sessions.Session, r render.Render, req *http.Request) {
src, err := handleSearch(req.URL.Query())
if err != nil {
r.Error(400)
}
status := common.GetCodeSourceStatus(src)
id := rand.Int63()
params := req.URL.Query()
usr := params.Get("user")
repo := params.Get("repo")
session.Set(id, usr+"/"+repo)
data := struct {
common.User
Pagename string
Theme string
SourceStatus string
WS_ID int64
Source *common.CodeSource
}{user, "search", "standard", string(status), id, src}
r.HTML(200, "search", data)
}
示例11: Edit
func Edit(rw http.ResponseWriter, req *http.Request, r render.Render, params martini.Params) {
c := appengine.NewContext(req)
var b banner.Banner
intID, err := strconv.Atoi(params["id"])
if err == nil {
b.ID = int64(intID)
}
if b.ID > 0 {
if err := b.Get(c); err != nil {
http.Redirect(rw, req, "/admin?error="+err.Error(), http.StatusFound)
return
}
}
uploadURL, err := blobstore.UploadURL(c, "/admin/banners/"+strconv.Itoa(intID), nil)
if err != nil {
http.Redirect(rw, req, "/admin?error="+err.Error(), http.StatusFound)
return
}
bag := make(map[string]interface{}, 0)
bag["Host"] = req.URL.Host
bag["Admin"] = true
bag["Banner"] = b
bag["URL"] = uploadURL
bag["ActiveNav"] = "banners"
r.HTML(200, "admin/banners/edit", bag)
return
}
示例12: Quote
func Quote(db model.Model, r render.Render, params martini.Params, isJson IsJson) {
id, err := strconv.Atoi(params["id"])
if err != nil {
RenderError(r, 404, isJson, "invalid quote id")
return
}
quote, err := db.GetQuote(id)
if err != nil {
RenderError(r, 404, isJson, "quote not found")
return
}
if isJson {
r.JSON(200, quote)
return
}
env := quotePageEnv{
PageEnv: PageEnv{Title: fmt.Sprintf("#%d", quote.ID)},
Quotes: []model.Quote{quote},
ShowPagination: false,
}
r.HTML(200, "quote", env)
}
示例13: CreateAdmin
func CreateAdmin(r render.Render, req *http.Request) {
if len(cache.Users) > 0 {
r.Error(404)
return
}
if req.Method == "GET" {
r.HTML(200, "user_add", map[string]interface{}{})
return
}
req.ParseForm()
values := req.Form
m := &model.User{}
m.Account = values.Get("account")
m.Password = model.Md5(values.Get("password"))
m.Info = values.Get("info")
m.Name = values.Get("name")
if !checkNull([]string{m.Account, m.Password, m.Info, m.Name}...) {
service.Logs.Error("args err")
return
}
m.Status = model.UserStatusAdmin
_, err := dao.AddUser(m)
if err != nil {
service.Logs.Error("dao.InsertUser err(%v)", err)
return
}
r.Redirect("/", 302)
return
}
示例14: EditInvertebrate
func EditInvertebrate(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) {
var invertebrate_id string = params["id"]
if invertebrate_id != "new" {
invertebrate, err := repository.GetInvertebrate(db, invertebrate_id)
if err != nil || invertebrate == nil {
t.SessionMessage.AddDanger("Failed to load invertebrate.")
ren.Redirect("/invertebrate")
return
}
id, _ := strconv.ParseInt(params["id"], 10, 64)
invertebrate.PopularNames.Names, err = repository.GetPopularNames(db, id, INVERTEBRATE)
t.Data = invertebrate
t.MediaList = getMediaList(db, INVERTEBRATE, id)
ren.HTML(200, "blah/invertebrate/edit", t)
} else {
ren.HTML(200, "blah/invertebrate/edit", nil)
}
}
示例15: Answer
func Answer(req *http.Request, r render.Render) {
returnData := make(map[string]interface{})
if req.Method == "GET" {
blankList, choiceList, judgeList := appService.GetTitleId(1, 1, 1)
returnData["blankList"] = blankList
returnData["choiceList"] = choiceList
returnData["judgeList"] = judgeList
r.HTML(200, "answer", returnData)
return
}
req.ParseForm()
values := req.Form
records := values.Get("records")
if records == "" {
r.Data(500, []byte("error"))
}
name, recordsList, err := appService.CheckRecords(records)
if err != nil {
r.Data(500, []byte("appService.CheckRecords error"))
}
returnData["name"] = name
returnData["list"] = recordsList
r.HTML(200, "record", returnData)
return
}