本文整理汇总了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, "/")
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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, "/")
}
示例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
}
示例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)
}
示例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
}