summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go')
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go b/vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go
new file mode 100644
index 000000000..2ef1eeac2
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/v2/internal/template.go
@@ -0,0 +1,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
+}