Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksnyder committed Jan 28, 2024
1 parent e08ef5b commit 9942436
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions v2/i18n/template_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,67 +84,3 @@ func (t *parsedTextTemplate) Execute(data any) (string, error) {
}

Check warning on line 84 in v2/i18n/template_engine.go

View check run for this annotation

Codecov / codecov/patch

v2/i18n/template_engine.go#L83-L84

Added lines #L83 - L84 were not covered by tests
return buf.String(), nil
}

// type TemplateEngine interface {
// Execute(src string, data any) (string, error)
// }

// type NoTemplateEngine struct{}

// func (*NoTemplateEngine) Execute(src string, data any) (string, error) {
// return src, nil
// }

// type TextTemplateEngine2 struct {
// LeftDelim string
// RightDelim string
// Funcs texttemplate.FuncMap
// Option string

// cache map[string]*executeResult
// cacheMutex sync.RWMutex
// }

// type executeResult struct {
// tmpl *texttemplate.Template
// err error
// }

// func (t *TextTemplateEngine2) Execute(src string, data any) (string, error) {
// tmpl, err := t.getTemplate(src)
// if err != nil {
// return "", err
// }
// var buf bytes.Buffer
// if err := tmpl.Execute(&buf, data); err != nil {
// return "", err
// }
// return buf.String(), nil
// }

// func (t *TextTemplateEngine2) getTemplate(template string) (*texttemplate.Template, error) {
// // It is not safe to use the cache if t.Funcs or t.Option is set.
// if t.Funcs != nil || t.Option != "" {
// return texttemplate.New("").Delims(t.LeftDelim, t.RightDelim).Funcs(t.Funcs).Option(t.Option).Parse(template)
// }

// // If there is a cached result, return it.
// t.cacheMutex.RLock()
// result := t.cache[template]
// t.cacheMutex.RUnlock()
// if result != nil {
// return result.tmpl, result.err
// }

// // Parse the template and save it to the cache
// tmpl, err := texttemplate.New("").Delims(t.LeftDelim, t.RightDelim).Parse(template)
// r := &executeResult{
// tmpl: tmpl,
// err: err,
// }
// t.cacheMutex.Lock()
// t.cache[template] = r
// t.cacheMutex.Unlock()

// return tmpl, err
// }

0 comments on commit 9942436

Please sign in to comment.