diff options
author | Wim <wim@42.be> | 2020-08-10 00:29:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 00:29:54 +0200 |
commit | 4e50fd864921c556988c919269448efdb90fa961 (patch) | |
tree | a3625f03f8de3c4f3841364000a4ea3aa42c1533 /vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go | |
parent | dfdffa0027334e55ce213fc6eb62206dbf48baf6 (diff) | |
download | matterbridge-msglm-4e50fd864921c556988c919269448efdb90fa961.tar.gz matterbridge-msglm-4e50fd864921c556988c919269448efdb90fa961.tar.bz2 matterbridge-msglm-4e50fd864921c556988c919269448efdb90fa961.zip |
Use mattermost v5 module (#1192)
Diffstat (limited to 'vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go')
-rw-r--r-- | vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go deleted file mode 100644 index c8756fa4..00000000 --- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go +++ /dev/null @@ -1,61 +0,0 @@ -package translation - -import ( - "bytes" - "encoding" - "strings" - gotemplate "text/template" -) - -type template struct { - tmpl *gotemplate.Template - src string -} - -func newTemplate(src string) (*template, error) { - var tmpl template - err := tmpl.parseTemplate(src) - return &tmpl, err -} - -func mustNewTemplate(src string) *template { - t, err := newTemplate(src) - if err != nil { - panic(err) - } - return t -} - -func (t *template) String() string { - return t.src -} - -func (t *template) Execute(args interface{}) string { - if t.tmpl == nil { - return t.src - } - var buf bytes.Buffer - if err := t.tmpl.Execute(&buf, args); err != nil { - return err.Error() - } - return buf.String() -} - -func (t *template) MarshalText() ([]byte, error) { - return []byte(t.src), nil -} - -func (t *template) UnmarshalText(src []byte) error { - return t.parseTemplate(string(src)) -} - -func (t *template) parseTemplate(src string) (err error) { - t.src = src - if strings.Contains(src, "{{") { - t.tmpl, err = gotemplate.New(src).Parse(src) - } - return -} - -var _ = encoding.TextMarshaler(&template{}) -var _ = encoding.TextUnmarshaler(&template{}) |