diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-05-12 15:08:58 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-12 16:37:29 -0400 |
commit | 84d2482ddbff9564c9ad75b2d30af66e3ddfd44d (patch) | |
tree | 8bfa567d2b6381f4a996ada2deff8a16aa85a3ac /Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go | |
parent | d1efb66ad7b017f0fbfe6f0c20843b30f396e504 (diff) | |
download | chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.tar.gz chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.tar.bz2 chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.zip |
Updating go depencancies. Switching to go1.6 vendoring (#2949)
Diffstat (limited to 'Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go deleted file mode 100644 index c8756fa4e..000000000 --- a/Godeps/_workspace/src/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{}) |