func layoutFunc(w http.ResponseWriter, r *http.Request) template.FuncMap { funcsMap := template.FuncMap{ "render": func(s interface{}) string { return "" }, } for k, v := range inline_edit.FuncMap(i18n.I18n, "en-US", false) { funcsMap[k] = v } return funcsMap }
func funcsMap(ctx *gin.Context) template.FuncMap { funcMaps := map[string]interface{}{ "related_products": func(cv models.ColorVariation) []models.Product { var products []models.Product db.DB.Preload("ColorVariations").Preload("ColorVariations.Images").Limit(4).Find(&products, "id <> ?", cv.ProductID) return products }, "other_also_bought": func(cv models.ColorVariation) []models.Product { var products []models.Product db.DB.Preload("ColorVariations").Preload("ColorVariations.Images").Order("id ASC").Limit(8).Find(&products, "id <> ?", cv.ProductID) return products }, } for key, value := range inline_edit.FuncMap(i18n.I18n, "en-US", isEditMode(ctx)) { funcMaps[key] = value } return funcMaps }
func I18nFuncMap(ctx *gin.Context) template.FuncMap { return inline_edit.FuncMap(i18n.I18n, CurrentLocale(ctx), IsEditMode(ctx)) }
func I18nFuncMap(ctx *gin.Context) template.FuncMap { return inline_edit.FuncMap(i18n.I18n, "en-US", isEditMode(ctx)) }