diff options
author | Alex <alex@scerba.org> | 2024-05-04 17:28:37 -0400 |
---|---|---|
committer | Alex Scerba <alex@scerba.org> | 2024-08-15 22:54:25 -0500 |
commit | 811c9bb2f7358ff094fe13deb6d961088baa2d8f (patch) | |
tree | 694010fbc71c9ff67cee28f6da1447290e627afe /cmd/http/render.go | |
parent | d9fc74778ef86b02f0a743821263db8873417294 (diff) |
Add Go webserver.
Diffstat (limited to 'cmd/http/render.go')
-rw-r--r-- | cmd/http/render.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cmd/http/render.go b/cmd/http/render.go new file mode 100644 index 0000000..585ba31 --- /dev/null +++ b/cmd/http/render.go @@ -0,0 +1,36 @@ +package main + +import ( + "net/http" + //"strings" + "text/template" +) + +func renderTemplate(w http.ResponseWriter, page string, p *Posts) (err error) { + t, err := template.ParseFiles("html/master.tmpl.html", "html/"+page+".tmpl.html") + if err != nil { + return err + } + + //splitPath := strings.Split(page, "/") + + //data := make(map[string]interface{}) + + // If were loading the index, set page to 'Index' and pass through all posts. + // Otherwise, set page to 'Projects' and pass through the first post (should only be one + // coming in) + /* if splitPath[0] == "index" { + data["Page"] = "Index" + data["Posts"] = p + } else { + data["Page"] = "Project" + data["Post"] = p.Contents[0] + } */ + + err = t.Execute(w, nil) + if err != nil { + return err + } + + return nil +} |