当前位置: 首页>>代码示例>>Golang>>正文


Golang Render.HTML方法代码示例

本文整理汇总了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)
}
开发者ID:tpiha,项目名称:barecv,代码行数:8,代码来源:views.go

示例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})
}
开发者ID:chinab,项目名称:enterprise-manage,代码行数:7,代码来源:login.go

示例3: getLoginPage

func getLoginPage(user sessionauth.User, r render.Render) {
	if user.IsAuthenticated() {
		r.Redirect(INDEX_PAGE)
		return
	}
	r.HTML(200, LOGIN_PAGE, nil)
}
开发者ID:jmptrader,项目名称:chatgo,代码行数:7,代码来源:user.go

示例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)
	}
}
开发者ID:gophergala2016,项目名称:chroniton,代码行数:7,代码来源:projects.go

示例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()
}
开发者ID:BurntSushi,项目名称:lcmweb,代码行数:28,代码来源:web.go

示例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)
}
开发者ID:gitter-badger,项目名称:khabar-admin,代码行数:26,代码来源:available.go

示例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)
}
开发者ID:neovintage,项目名称:nightcrawler,代码行数:7,代码来源:authentication.go

示例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
}
开发者ID:sasimpson,项目名称:cfpaste,代码行数:35,代码来源:cfpaste.go

示例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)
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:25,代码来源:component.go

示例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)
}
开发者ID:SemQuery,项目名称:web,代码行数:27,代码来源:query.go

示例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
}
开发者ID:ninnemana,项目名称:dynamicfab,代码行数:32,代码来源:banners.go

示例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)
}
开发者ID:firba1,项目名称:irq,代码行数:25,代码来源:quote.go

示例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
}
开发者ID:go-galaxy,项目名称:galaxy,代码行数:30,代码来源:admin.go

示例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)
	}
}
开发者ID:peteraba,项目名称:go-blah,代码行数:27,代码来源:invertebrate.go

示例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
}
开发者ID:leisunstar,项目名称:hxs,代码行数:25,代码来源:api.go


注:本文中的github.com/martini-contrib/render.Render.HTML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。