]> Cypherpunks repositories - gostls13.git/commitdiff
treat "" as empty
authorRuss Cox <rsc@golang.org>
Wed, 15 Apr 2009 07:26:49 +0000 (00:26 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 15 Apr 2009 07:26:49 +0000 (00:26 -0700)
R=r
DELTA=10  (10 added, 0 deleted, 0 changed)
OCL=27479
CL=27481

src/lib/template/template.go
src/lib/template/template_test.go

index fbffa9562b63596921404c67bc4e6e5a60054c03..f81ac0adaf26835f9e613a07bacfdab47457f263 100644 (file)
@@ -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:
index 2124e8d95a5c5d00637e475618993a6c7896c122..aab0c9cc6e0a3c55e33c04dd8918d27f91ef57de 100644 (file)
@@ -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"
                "&amp;&lt;&gt;!@ #$%^\n"
        },
+
+       &Test{
+               "{.section emptystring}emptystring{.end}\n"
+               "{.section header}header{.end}\n",
+
+               "\nheader\n"
+       },
 }
 
 func TestAll(t *testing.T) {