Commit 5c5ce6d2 authored by Roger Peppe's avatar Roger Peppe Committed by Rob Pike

exp/template: ensure that a valid Set is returned even on error.

R=r
CC=golang-dev
https://golang.org/cl/4838044
parent 317911c9
......@@ -97,6 +97,7 @@ func (s *Set) ParseFile(filenames ...string) (*Set, os.Error) {
// named files. Each file must be individually parseable.
func ParseSetFile(filenames ...string) (*Set, os.Error) {
s := new(Set)
s.init()
for _, filename := range filenames {
b, err := ioutil.ReadFile(filename)
if err != nil {
......@@ -193,6 +194,7 @@ func (s *Set) ParseTemplateFiles(pattern string) (*Set, os.Error) {
// encountered.
func ParseTemplateFile(filenames ...string) (*Set, os.Error) {
set := new(Set)
set.init()
for _, filename := range filenames {
t, err := ParseFile(filename)
if err != nil {
......@@ -217,6 +219,7 @@ func ParseTemplateFile(filenames ...string) (*Set, os.Error) {
// encountered.
func ParseTemplateFiles(pattern string) (*Set, os.Error) {
set := new(Set)
set.init()
filenames, err := filepath.Glob(pattern)
if err != nil {
return set, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment