feat(xtemplate): init package, Template interface

New package focused on improving text/template and html/template std
packages.
This commit is contained in:
Guz
2025-10-21 21:44:42 -03:00
parent 6ea200aa64
commit ad84857ea7

31
xtemplate/xtemplate.go Normal file
View File

@@ -0,0 +1,31 @@
package xtemplate
import (
"io"
"io/fs"
"text/template/parse"
)
type Template interface {
AddParseTree(name string, tree *parse.Tree) (Template, error)
Clone() (Template, error)
DefinedTemplates() string
Delims(left, right string) Template
Funcs(funcMap template.FuncMap) Template
Lookup(name string) Template
Name() string
New(name string) Template
Option(opt ...string) Template
Parse(text string) (Template, error)
ParseFS(fs fs.FS, patterns ...string) (Template, error)
ParseFiles(filenames ...string) (Template, error)
ParseGlob(pattern string) (Template, error)
Templates() []Template
Templater
}
type Templater interface {
Execute(wr io.Writer, data any) error
ExecuteTemplate(wr io.Writer, name string, data any) error
}