fix template error if no template string is defined
This commit is contained in:
parent
d7c0b7f488
commit
04b61f6d9a
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue