Enabling Go Modules and refactoring our code to use packages

This commit is contained in:
2024-04-17 17:06:39 -06:00
parent a64a032324
commit 72ac372111
4 changed files with 56 additions and 0 deletions

17
pkg/render/render.go Normal file
View File

@@ -0,0 +1,17 @@
package render
import (
"fmt"
"net/http"
"text/template"
)
// RenderTemplate renders templates using html/template
func RenderTemplate(w http.ResponseWriter, tmpl string) {
parsedTemplate, _ := template.ParseFiles("./templates/" + tmpl)
err := parsedTemplate.Execute(w, nil)
if err != nil {
fmt.Println("error parsing template:", err)
return
}
}