當前位置: 首頁>>代碼示例>>Golang>>正文


Golang mangotemplate.ForRender函數代碼示例

本文整理匯總了Golang中github.com/sunfmin/mangotemplate.ForRender函數的典型用法代碼示例。如果您正苦於以下問題:Golang ForRender函數的具體用法?Golang ForRender怎麽用?Golang ForRender使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ForRender函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/sunfmin/mangotemplate.ForRender函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。