diff --git a/src/lib/template/template.go b/src/lib/template/template.go index fbffa9562b6..f81ac0adaf2 100644 --- a/src/lib/template/template.go +++ b/src/lib/template/template.go @@ -308,6 +308,8 @@ func empty(v reflect.Value, indirect_ok bool) bool { return true } switch v.Type().Kind() { + case reflect.StringKind: + return v.(reflect.StringValue).Get() == ""; case reflect.StructKind: return false; case reflect.ArrayKind: diff --git a/src/lib/template/template_test.go b/src/lib/template/template_test.go index 2124e8d95a5..aab0c9cc6e0 100644 --- a/src/lib/template/template_test.go +++ b/src/lib/template/template_test.go @@ -29,6 +29,7 @@ type S struct { data []T; pdata []*T; empty []*T; + emptystring string; null []*T; } @@ -162,14 +163,21 @@ var tests = []*Test { "HEADER=78\n" "Header=77\n" }, - + &Test{ "{raw}\n" "{raw|html}\n", - + "&<>!@ #$%^\n" "&<>!@ #$%^\n" }, + + &Test{ + "{.section emptystring}emptystring{.end}\n" + "{.section header}header{.end}\n", + + "\nheader\n" + }, } func TestAll(t *testing.T) {