package Webserver import ( "html/template" "net/http" "path" "PersonalWebsite/Helper" ) type Unauthenticated struct { FlashMsg string } var ( partials = []string{ "html/header.gohtml", "html/sidebar.gohtml", } ) func ServeTemplate(w http.ResponseWriter, r *http.Request, mainFile string, v map[string]interface{}) { var ( tpl *template.Template files []string e error ) v["test"] = "Yeet" files = []string{webRootJoin(mainFile)} for _, p := range partials { files = append(files, webRootJoin(p)) } tpl, e = template.New(path.Base(files[0])).Funcs( template.FuncMap{ "FormatTimestamp": Helper.FormatTimestamp, }, ).ParseFiles(files...) if e != nil { // TODO: Handle this panic(e) } w.Header().Set("Content-type", "text/html") e = tpl.Execute(w, v) if e != nil { // TODO: Handle this panic(e) } }