fix template error if no template string is defined

This commit is contained in:
Christoph Oelmueller 2016-04-01 10:23:34 +02:00
parent d7c0b7f488
commit 04b61f6d9a
1 changed files with 6 additions and 0 deletions

View File

@ -82,6 +82,9 @@ func FromGlobs(paths ...string) (*Template, error) {
// ExecuteTextString needs a meaningful doc comment (TODO(fabxc)). // ExecuteTextString needs a meaningful doc comment (TODO(fabxc)).
func (t *Template) ExecuteTextString(text string, data interface{}) (string, error) { func (t *Template) ExecuteTextString(text string, data interface{}) (string, error) {
if text == "" {
return "", nil
}
tmpl, err := t.text.Clone() tmpl, err := t.text.Clone()
if err != nil { if err != nil {
return "", err return "", err
@ -97,6 +100,9 @@ func (t *Template) ExecuteTextString(text string, data interface{}) (string, err
// ExecuteHTMLString needs a meaningful doc comment (TODO(fabxc)). // ExecuteHTMLString needs a meaningful doc comment (TODO(fabxc)).
func (t *Template) ExecuteHTMLString(html string, data interface{}) (string, error) { func (t *Template) ExecuteHTMLString(html string, data interface{}) (string, error) {
if html == "" {
return "", nil
}
tmpl, err := t.html.Clone() tmpl, err := t.html.Clone()
if err != nil { if err != nil {
return "", err return "", err