diff --git a/cmd/main.go b/cmd/main.go index cec7841..d8dd3a5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -12,14 +12,77 @@ func main() { http.HandleFunc("/data", func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(200) const tpl = ` -

Hey check out the data

+
+
+ + + + + + + + + + + {{range .Users}} + + + + + + + {{end}} + +
NameEmailRoleStatus
+
+
+ {{.Initials}} +
+
{{.Name}}
+
+
{{.Email}} + + {{.Role}} + + + + + {{.Status}} + +
+
+
` t, err := template.New("default").Parse(tpl) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - err = t.Execute(w, nil) + + type User struct { + Name string + Initials string + Email string + Role string + Status string + StatusClass string + StatusDotClass string + } + + data := struct { + Users []User + }{ + Users: []User{ + {Name: "Sarah Chen", Initials: "SC", Email: "sarah.chen@example.com", Role: "Engineering", Status: "Active", StatusClass: "bg-green-50 text-green-600", StatusDotClass: "bg-green-600"}, + {Name: "Marcus Johnson", Initials: "MJ", Email: "marcus.j@example.com", Role: "Product", Status: "Active", StatusClass: "bg-green-50 text-green-600", StatusDotClass: "bg-green-600"}, + {Name: "Emma Rodriguez", Initials: "ER", Email: "emma.r@example.com", Role: "Design", Status: "Away", StatusClass: "bg-yellow-50 text-yellow-600", StatusDotClass: "bg-yellow-600"}, + {Name: "James Wilson", Initials: "JW", Email: "james.w@example.com", Role: "Marketing", Status: "Active", StatusClass: "bg-green-50 text-green-600", StatusDotClass: "bg-green-600"}, + {Name: "Priya Patel", Initials: "PP", Email: "priya.p@example.com", Role: "Sales", Status: "Inactive", StatusClass: "bg-gray-50 text-gray-600", StatusDotClass: "bg-gray-400"}, + {Name: "Alex Kim", Initials: "AK", Email: "alex.kim@example.com", Role: "Engineering", Status: "Active", StatusClass: "bg-green-50 text-green-600", StatusDotClass: "bg-green-600"}, + }, + } + + err = t.Execute(w, data) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return