GoWeb/templating/templateHelper.go

21 lines
384 B
Go
Raw Normal View History

package templating
import (
"GoWeb/app"
"html/template"
"log"
"net/http"
)
func RenderTemplate(app *app.App, w http.ResponseWriter, contentPath string, data any) {
templatePath := app.Config.Template.BaseName
t, _ := template.ParseFiles(templatePath, contentPath)
err := t.Execute(w, data)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), 500)
return
}
}