1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:54:45 -07:00

exp/template: make Set.MustParse* methods return the set.

This brings them into line with the Template.MustParse* methods
and makes it possible to use them in global variable initializations.

R=r
CC=golang-dev
https://golang.org/cl/4798059
This commit is contained in:
Roger Peppe 2011-07-28 08:41:06 -07:00 committed by Rob Pike
parent fa249cae38
commit 3041f2a37c

View File

@ -192,11 +192,12 @@ func (s *Set) ParseTemplateFile(filenames ...string) os.Error {
// MustParseTemplateFile is like ParseTemplateFile but
// panics if there is an error.
func (s *Set) MustParseTemplateFile(filenames ...string) {
func (s *Set) MustParseTemplateFile(filenames ...string) *Set {
err := s.ParseTemplateFile(filenames...)
if err != nil {
panic(err)
}
return s
}
// ParseTemplateFiles parses the template files matched by the
@ -228,11 +229,12 @@ func (s *Set) ParseTemplateFiles(pattern string) os.Error {
// MustParseTemplateFile is like ParseTemplateFiles but
// panics if there is an error.
func (s *Set) MustParseTemplateFiles(pattern string) {
func (s *Set) MustParseTemplateFiles(pattern string) *Set {
err := s.ParseTemplateFiles(pattern)
if err != nil {
panic(err)
}
return s
}
// ParseTemplateFile creates a set by parsing the named files,