Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
c8b78dbb86 | |||
1823a432f8 | |||
7e32ff6f91 |
1 changed files with 3 additions and 3 deletions
|
@ -2,9 +2,9 @@ package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"embed"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Engine is a template engine
|
// Engine is a template engine
|
||||||
|
@ -24,8 +24,8 @@ func (e *Engine) Render(name string, data any) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTemplateEngine creates a new template engine from the given templates
|
// NewTemplateEngine creates a new template engine from the given templates
|
||||||
func NewEngine(templates embed.FS) (*Engine, error) {
|
func NewEngine(templates fs.FS) (*Engine, error) {
|
||||||
tmpls, err := template.ParseFS(templates, "**/*.html")
|
tmpls, err := template.ParseFS(templates, "*.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse templates: %w", err)
|
return nil, fmt.Errorf("failed to parse templates: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue