gonotes/internal/templ/templ.go

19 lines
430 B
Go

package templ
import (
"html/template"
"net/http"
"path/filepath"
"gitea.gwairfelin.com/max/gonotes/internal/conf"
)
func RenderTemplate(w http.ResponseWriter, tmpl string, context any) error {
files := []string{
filepath.Join(conf.Conf.TemplatesDir, conf.Conf.BaseTemplate),
filepath.Join(conf.Conf.TemplatesDir, tmpl),
}
t, err := template.ParseFiles(files...)
t.ExecuteTemplate(w, "base", context)
return err
}