• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang mangotemplate.ForRender函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/sunfmin/mangotemplate.ForRender函数的典型用法代码示例。如果您正苦于以下问题:Golang ForRender函数的具体用法?Golang ForRender怎么用?Golang ForRender使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ForRender函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: SignupAction

func SignupAction(env Env) (status Status, headers Headers, body Body) {

	user := users.NewUser()
	formdata.UnmarshalByNames(env.Request().Request, user,
		[]string{"Email", "Name", "Password", "ConfirmPassword"})

	if validated := user.ValidateSignupForm(); validated.HasError() {
		mangotemplate.ForRender(env, "sessions/signup", &SessionData{User: user, Validated: validated})
		return
	}

	if validated := user.ValidateEmailExist(); validated.HasError() {
		mangotemplate.ForRender(env, "sessions/signup", &SessionData{User: user, Validated: validated})
		return
	}

	if err := user.Signup(); err != nil {
		panic(err)
		return
	}

	services.PutUserIdToSession(env, user.Id.Hex())

	return Redirect(http.StatusFound, "/")
}
开发者ID:kobeld,项目名称:duoerl,代码行数:25,代码来源:session_handlers.go


示例2: Edit

func Edit(env Env) (status Status, headers Headers, body Body) {

	brandId := env.Request().URL.Query().Get(":id")
	brandInput, err := services.EditBrand(brandId)
	if validated, ok := err.(*govalidations.Validated); ok {
		mangotemplate.ForRender(env, "brands/edit", newBrandViewData(brandInput, validated))
		return
	}
	if err != nil {
		panic(err)
	}

	mangotemplate.ForRender(env, "brands/edit", newBrandViewData(brandInput, nil))
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:15,代码来源:brand_handlers.go


示例3: Index

func Index(env Env) (status Status, headers Headers, body Body) {

	apiProducts, err := services.AllProducts()
	if err != nil {
		panic(err)
	}

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	apiUsers, err := services.GetUsers()
	if err != nil {
		panic(err)
	}

	homeViewData := &HomeViewData{
		ApiProducts: apiProducts,
		ApiBrands:   apiBrands,
		ApiUsers:    apiUsers,
	}

	mangotemplate.ForRender(env, "feeds/index", homeViewData)

	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:27,代码来源:feed_handlers.go


示例4: Show

func Show(env Env) (status Status, headers Headers, body Body) {
	id := env.Request().URL.Query().Get(":id")

	apiUser, err := services.GetUser(id)
	if err != nil {
		panic(err)
	}

	apiNotes, err := services.GetUserNotes(id)
	if err != nil {
		panic(err)
	}

	apiPosts, err := services.GetUserPosts(id)
	if err != nil {
		panic(err)
	}

	userViewData := &UserViewData{
		ApiUser:   apiUser,
		ApiNotes:  apiNotes,
		ApiPosts:  apiPosts,
		NewPostId: bson.NewObjectId().Hex(),
		IsCurrent: services.IsCurrentUserWithId(env, id),
	}

	mangotemplate.ForRender(env, "users/show", userViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:29,代码来源:user_handlers.go


示例5: Show

func Show(env Env) (status Status, headers Headers, body Body) {
	productId := env.Request().URL.Query().Get(":id")
	currentUserId := services.FetchUserIdFromSession(env)

	// Get Product
	apiProduct, err := services.ShowProduct(productId, currentUserId)
	if err != nil {
		panic(err)
	}

	// Get Product Reviews
	apiReviews, err := services.GetReviewsInProduct(productId)
	if err != nil {
		panic(err)
	}

	// Init new Review Form data
	productViewData := &ProductViewData{
		ApiProduct:     apiProduct,
		ApiReviews:     apiReviews,
		ReviewInput:    services.NewReview(),
		GotFromOptions: global.GotFromOptions,
		RatingOptions:  global.RatingOptions,
	}

	mangotemplate.ForRender(env, "products/show", productViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:28,代码来源:product_handlers.go


示例6: LoginPage

func LoginPage(env Env) (status Status, headers Headers, body Body) {
	user := services.FetchUserFromEnv(env)
	if user != nil {
		return Redirect(http.StatusFound, "/")
	}
	mangotemplate.ForRender(env, "sessions/login", &SessionData{User: users.NewUser()})
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:8,代码来源:session_handlers.go


示例7: Index

func Index(env Env) (status Status, headers Headers, body Body) {
	a := &accounts.Account{
		Name:       "Felix",
		Gender:     "2",
		Department: "IT",
	}
	mangotemplate.ForRender(env, "home/index", forms.AccountRegisterForm().Render(a, env))
	return
}
开发者ID:jmptrader,项目名称:gowebapp,代码行数:9,代码来源:handlers.go


示例8: Index

func Index(env Env) (status Status, headers Headers, body Body) {

	apiProducts, err := services.AllProducts()
	if err != nil {
		panic(err)
	}
	mangotemplate.ForRender(env, "products/index", &ProductViewData{ApiProducts: apiProducts})
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:9,代码来源:product_handlers.go


示例9: Index

func Index(env Env) (status Status, headers Headers, body Body) {

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	mangotemplate.ForRender(env, "brands/index", &BrandViewData{ApiBrands: apiBrands})
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:10,代码来源:brand_handlers.go


示例10: Index

func Index(env Env) (status Status, headers Headers, body Body) {

	viewData := &AdminCategoryViewData{
		CategoryInput: new(duoerlapi.CategoryInput),
		ApiCategories: services.GetCategories(),
	}

	mangotemplate.ForRender(env, "admin/categories", viewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:10,代码来源:category_handlers.go


示例11: New

func New(env Env) (status Status, headers Headers, body Body) {

	noteInput := services.NewNote()

	noteViewData := &NoteViewData{
		NoteInput: noteInput,
	}

	mangotemplate.ForRender(env, "notes/new", noteViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:11,代码来源:note_handlers.go


示例12: LoginAction

func LoginAction(env Env) (status Status, headers Headers, body Body) {
	user := users.NewUser()
	formdata.UnmarshalByNames(env.Request().Request, user, []string{"Email", "Password"})

	validated := user.ValidateLoginForm()
	if validated.HasError() {
		mangotemplate.ForRender(env, "sessions/login", &SessionData{User: user, Validated: validated})
		return
	}

	loginUser := users.LoginWith(user.Email, user.Password)
	if loginUser == nil {
		validated.AddError("Password", "User and password do not match!")
		mangotemplate.ForRender(env, "sessions/login", &SessionData{User: user, Validated: validated})
		return
	}

	services.PutUserIdToSession(env, loginUser.Id.Hex())
	return Redirect(http.StatusFound, "/")
}
开发者ID:kobeld,项目名称:duoerl,代码行数:20,代码来源:session_handlers.go


示例13: Join

func Join(env Env) (status Status, headers Headers, body Body) {
	email := env.Request().FormValue("email")
	if email == "" {
		return Redirect(http.StatusFound, "/")
	}

	r := env.Request()
	mangotemplate.ForRender(env, "chats/room", &RenderData{Email: email, WebSocketHost: r.Host})
	headers = Headers{}
	return
}
开发者ID:kissthink,项目名称:gochatting-cn,代码行数:11,代码来源:chat.go


示例14: Create

func Create(env Env) (status Status, headers Headers, body Body) {

	brandInput := new(duoerlapi.BrandInput)
	formdata.UnmarshalByNames(env.Request().Request, &brandInput, brandFields)

	result, err := services.CreateBrand(brandInput)
	if validated, ok := err.(*govalidations.Validated); ok {
		mangotemplate.ForRender(env, "brands/new", newBrandViewData(result, validated))
		return
	}
	if err != nil {
		panic(err)
	}

	return Redirect(http.StatusFound, "/brand/"+result.Id)
}
开发者ID:kobeld,项目名称:duoerl,代码行数:16,代码来源:brand_handlers.go


示例15: New

func New(env Env) (status Status, headers Headers, body Body) {

	newsInput := services.NewNews()
	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	newsViewData := &NewsViewData{
		NewsInput: newsInput,
		ApiBrands: apiBrands,
	}

	mangotemplate.ForRender(env, "news/new", newsViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:16,代码来源:news_handlers.go


示例16: New

func New(env Env) (status Status, headers Headers, body Body) {
	productInput := services.NewProduct()
	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	productViewData := &ProductViewData{
		ProductInput:  productInput,
		ApiBrands:     apiBrands,
		ApiCategories: services.GetCategories(),
	}

	mangotemplate.ForRender(env, "products/new", productViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:16,代码来源:product_handlers.go


示例17: Show

func Show(env Env) (status Status, headers Headers, body Body) {
	newsId := env.Request().URL.Query().Get(":id")
	currentUserId := services.FetchUserIdFromSession(env)

	apiNews, err := services.ShowNews(newsId, currentUserId)
	if err != nil {
		panic(err)
	}

	newsViewData := &NewsViewData{
		ApiNews: apiNews,
	}

	mangotemplate.ForRender(env, "news/show", newsViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:16,代码来源:news_handlers.go


示例18: Edit

func Edit(env Env) (status Status, headers Headers, body Body) {
	id := services.FetchUserIdFromSession(env)

	apiUser, err := services.GetUser(id)
	if err != nil {
		panic(err)
	}

	userViewData := &UserViewData{
		ApiUser:            apiUser,
		SkinTextureOptions: global.SkinTextureOptions,
		HairTextureOptions: global.HairTextureOptions,
	}

	mangotemplate.ForRender(env, "users/edit", userViewData)
	return
}
开发者ID:kobeld,项目名称:duoerl,代码行数:17,代码来源:user_handlers.go


示例19: Create

func Create(env Env) (status Status, headers Headers, body Body) {

	reviewInput := new(duoerlapi.ReviewInput)
	formdata.UnmarshalByNames(env.Request().Request, &reviewInput, reviewFields)
	reviewInput.AuthorId = services.FetchUserIdFromSession(env)

	result, err := services.CreateReview(reviewInput)
	if validated, ok := err.(*govalidations.Validated); ok {
		// TODO: Ajax needed here
		mangotemplate.ForRender(env, "products/new", validated)
		return
	}
	if err != nil {
		panic(err)
	}

	return Redirect(http.StatusFound, "/product/"+result.ProductId)
}
开发者ID:kobeld,项目名称:duoerl,代码行数:18,代码来源:review_handlers.go


示例20: Update

func Update(env Env) (status Status, headers Headers, body Body) {
	newsInput := new(duoerlapi.NewsInput)
	formdata.UnmarshalByNames(env.Request().Request, &newsInput, newsFields)

	result, err := services.UpdateNews(newsInput)
	if validated, ok := err.(*govalidations.Validated); ok {
		viewData := &NewsViewData{
			NewsInput: newsInput,
			Validated: validated,
		}
		mangotemplate.ForRender(env, "news/edit", viewData)
		return
	}

	if err != nil {
		panic(err)
	}

	return Redirect(http.StatusFound, "/news/"+result.Id)
}
开发者ID:kobeld,项目名称:duoerl,代码行数:20,代码来源:news_handlers.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gotools.Trace函数代码示例发布时间:2022-05-29
下一篇:
Golang fuse.Attr类代码示例发布时间:2022-05-29
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap