blob: 2ef1eeac2c6bce3c719bb31bd796181eed55a020 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package internal
import (
"strings"
gotemplate "text/template"
)
// Template stores the template for a string.
type Template struct {
Src string
Template *gotemplate.Template
ParseErr *error
}
func (t *Template) parse(leftDelim, rightDelim string, funcs gotemplate.FuncMap) error {
if t.ParseErr == nil {
if strings.Contains(t.Src, leftDelim) {
gt, err := gotemplate.New("").Funcs(funcs).Delims(leftDelim, rightDelim).Parse(t.Src)
t.Template = gt
t.ParseErr = &err
} else {
t.ParseErr = new(error)
}
}
return *t.ParseErr
}
|