diff --git a/views/template.go b/views/template.go index ad2e4db..6ab7254 100644 --- a/views/template.go +++ b/views/template.go @@ -7,6 +7,7 @@ import ( "io/fs" "log" "net/http" + "os" ) type Template struct { @@ -26,14 +27,9 @@ func (t Template) ExecuteWriter(w io.Writer, data interface{}) error { return t.htmlTpl.Execute(w, data) } -func FromFile(filepath string) (Template, error) { - tpl, err := template.ParseFiles(filepath) - if err != nil { - return Template{}, fmt.Errorf("Error parsing template: %v", err) - } - return Template{ - htmlTpl: tpl, - }, nil +func FromFile(pattern ...string) (Template, error) { + fs := os.DirFS(".") + return FromFS(fs, pattern...) } func FromFS(fs fs.FS, pattern ...string) (Template, error) { tpl, err := template.ParseFS(fs, pattern...)