90 lines
2.1 KiB
Go
90 lines
2.1 KiB
Go
package xtemplate
|
|
|
|
import (
|
|
"io"
|
|
"io/fs"
|
|
"text/template"
|
|
"text/template/parse"
|
|
)
|
|
|
|
type textTemplate struct {
|
|
text *template.Template
|
|
}
|
|
|
|
var _ Template = (*textTemplate)(nil)
|
|
|
|
func (t *textTemplate) AddParseTree(name string, tree *parse.Tree) (Template, error) {
|
|
temp, err := t.text.AddParseTree(name, tree)
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) Clone() (Template, error) {
|
|
temp, err := t.text.Clone()
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) Delims(left, right string) Template {
|
|
return &textTemplate{t.text.Delims(left, right)}
|
|
}
|
|
|
|
func (t *textTemplate) DefinedTemplates() string {
|
|
return t.text.DefinedTemplates()
|
|
}
|
|
|
|
func (t *textTemplate) Execute(wr io.Writer, data any) error {
|
|
return t.text.Execute(wr, data)
|
|
}
|
|
|
|
func (t *textTemplate) ExecuteTemplate(wr io.Writer, name string, data any) error {
|
|
return t.text.ExecuteTemplate(wr, name, data)
|
|
}
|
|
|
|
func (t *textTemplate) Funcs(funcMap template.FuncMap) Template {
|
|
return &textTemplate{t.text.Funcs(funcMap)}
|
|
}
|
|
|
|
func (t *textTemplate) Lookup(name string) Template {
|
|
return &textTemplate{t.text.Lookup(name)}
|
|
}
|
|
|
|
func (t *textTemplate) Name() string {
|
|
return t.text.Name()
|
|
}
|
|
|
|
func (t *textTemplate) New(name string) Template {
|
|
return &textTemplate{t.text.New(name)}
|
|
}
|
|
|
|
func (t *textTemplate) Option(opt ...string) Template {
|
|
return &textTemplate{t.text.Option(opt...)}
|
|
}
|
|
|
|
func (t *textTemplate) Parse(text string) (Template, error) {
|
|
temp, err := t.text.Parse(text)
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) ParseFS(fs fs.FS, patterns ...string) (Template, error) {
|
|
temp, err := t.text.ParseFS(fs, patterns...)
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) ParseFiles(filenames ...string) (Template, error) {
|
|
temp, err := t.text.ParseFiles(filenames...)
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) ParseGlob(pattern string) (Template, error) {
|
|
temp, err := t.text.ParseGlob(pattern)
|
|
return &textTemplate{temp}, err
|
|
}
|
|
|
|
func (t *textTemplate) Templates() []Template {
|
|
texttemps := t.text.Templates()
|
|
temps := make([]Template, len(texttemps))
|
|
for i := range len(temps) {
|
|
temps[i] = &textTemplate{texttemps[i]}
|
|
}
|
|
return temps
|
|
}
|