template: two bug fixes / nits
  * diagnose template not created with New
    (current code just crashes)
  * write []byte uninterpreted
    (current code writes fmt format: "[65 65 65 65]")

R=r
CC=golang-dev
https://golang.org/cl/161075
diff --git a/src/pkg/template/format.go b/src/pkg/template/format.go
index e79469e..f357ab2 100644
--- a/src/pkg/template/format.go
+++ b/src/pkg/template/format.go
@@ -18,7 +18,11 @@
 // You can override the default formatter by storing your default
 // under the name "" in your custom formatter map.
 func StringFormatter(w io.Writer, value interface{}, format string) {
-	fmt.Fprint(w, value)
+	if b, ok := value.([]byte); ok {
+		w.Write(b);
+		return;
+	}
+	fmt.Fprint(w, value);
 }
 
 var (
diff --git a/src/pkg/template/template.go b/src/pkg/template/template.go
index 0a713de..9bba532 100644
--- a/src/pkg/template/template.go
+++ b/src/pkg/template/template.go
@@ -847,6 +847,9 @@
 // s contains the template text.  If any errors occur, Parse returns
 // the error.
 func (t *Template) Parse(s string) os.Error {
+	if t.elems == nil {
+		return &Error{1, "template not allocated with New"}
+	}
 	if !validDelim(t.ldelim) || !validDelim(t.rdelim) {
 		return &Error{1, fmt.Sprintf("bad delimiter strings %q %q", t.ldelim, t.rdelim)}
 	}
diff --git a/src/pkg/template/template_test.go b/src/pkg/template/template_test.go
index 7384da9..379f0f3 100644
--- a/src/pkg/template/template_test.go
+++ b/src/pkg/template/template_test.go
@@ -9,6 +9,7 @@
 	"container/vector";
 	"fmt";
 	"io";
+	"strings";
 	"testing";
 )
 
@@ -41,6 +42,7 @@
 	false		bool;
 	mp		map[string]string;
 	innermap	U;
+	bytes		[]byte;
 }
 
 var t1 = T{"ItemNumber1", "ValueNumber1"}
@@ -282,6 +284,12 @@
 		out: "1\n4\n",
 	},
 
+	&Test{
+		in: "{bytes}",
+
+		out: "hello",
+	},
+
 	// Maps
 
 	&Test{
@@ -317,6 +325,7 @@
 	s.mp["mapkey"] = "Ahoy!";
 	s.innermap.mp = make(map[string]int);
 	s.innermap.mp["innerkey"] = 55;
+	s.bytes = strings.Bytes("hello");
 
 	var buf bytes.Buffer;
 	for _, test := range tests {