package blog import ( "gobeyhan/database/models" "fmt" ) templ CategoryList(items []models.Category) { @Layout("Blog Categories") {

Categories

Add Category
for _, cat := range items { }
ID Title Slug Order Active Actions
{ fmt.Sprintf("%d", cat.ID) } { cat.Title } { cat.Slug } { fmt.Sprintf("%d", cat.Order) } if cat.IsActive { Active } else { Inactive } Edit
} } templ CategoryForm(cat *models.Category, categories []models.Category, errors map[string]string) { @Layout(ifElse(cat.ID == 0, "Create Category", "Edit Category")) {

if cat.ID == 0 { Create New Category } else { Edit Category: { cat.Title } }

if errors["title"] != "" {

{ errors["title"] }

}
Cancel
} } func ifElse(cond bool, a, b string) string { if cond { return a } return b }