package models
import (
"net/http"
"html/template"
)
type Page struct {
Path string
Template string
Data map[string]interface{}
}
func (p Page) HandlePage(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles(p.Template, "templates/base.html")
t.ExecuteTemplate(w, "base", p.Data)
}
type Category struct {
Id uint
Name string
}
type Product struct {
Id uint
Category Category
Name string
Description string
ImgUrl string
Quantity uint
Price uint
}
var Pages map[string]Page
var Categories []Category
var Products []Product
func GetCategoryByName(name string) Category {
var category Category
for i:= range Categories {
if Categories[i].Name == name {
category = Categories[i]
break
}
}
return category
}