Refactoring code to use packages

This commit is contained in:
Muyao CHEN
2024-06-26 22:06:32 +02:00
parent b207b9a293
commit 144e700b15
3 changed files with 10 additions and 8 deletions

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

@ -0,0 +1,16 @@
package render
import (
"fmt"
"html/template"
"net/http"
)
// renderTemplate renders a HTML template file
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)
}
}