func MustParseFiles(t Template, filenames ...string) {
	must(ParseFiles(t, filenames...))
}
MustParseFiles is like ParseFiles but panics on error.
package tmplfunc
import (
	"fmt"
	"io/ioutil"
	"path/filepath"
	htmltemplate "html/template"
	texttemplate "text/template"
)
type Template interface {
	DefinedTemplates() string
	Name() string
}
func Parse(t Template, text string) error {
	if err := funcs(t, []string{t.Name()}, []string{text}); err != nil {
		return err
	}
	var err error
	switch t := t.(type) {
	case *texttemplate.Template:
		_, err = t.Parse(text)
	case *htmltemplate.Template:
		_, err = t.Parse(text)
	}
	return err
}
func ParseFiles(t Template, filenames ...string) error {
	return parseFiles(t, readFileOS, filenames...)
}
func parseFiles(t Template, readFile func(string) (string, []byte, error), filenames ...string) error {
	if len(filenames) == 0 {
		return fmt.Errorf("tmplfunc: no files named in call to ParseFiles")
	}
	var names []string
	var texts []string
	for _, filename := range filenames {
		name, b, err := readFile(filename)
		if err != nil {
			return err
		}
		names = append(names, name)
		texts = append(texts, string(b))
	}
	err := funcs(t, names, texts)
	if err != nil {
		return err
	}
	switch t := t.(type) {
	case *texttemplate.Template:
		for i, name := range names {
			var tmpl *texttemplate.Template
			if name == t.Name() {
				tmpl = t
			} else {
				tmpl = t.New(name)
			}
			if _, err := tmpl.Parse(texts[i]); err != nil {
				return err
			}
		}
	case *htmltemplate.Template:
		for i, name := range names {
			var tmpl *htmltemplate.Template
			if name == t.Name() {
				tmpl = t
			} else {
				tmpl = t.New(name)
			}
			if _, err := tmpl.Parse(texts[i]); err != nil {
				return err
			}
		}
	}
	return nil
}
func ParseGlob(t Template, pattern string) error {
	filenames, err := filepath.Glob(pattern)
	if err != nil {
		return err
	}
	if len(filenames) == 0 {
		return fmt.Errorf("tmplfunc: pattern matches no files: %#q", pattern)
	}
	return parseFiles(t, readFileOS, filenames...)
}
func must(err error) {
	if err != nil {
		panic(err)
	}
}
func MustParse(t Template, text string) {
	must(Parse(t, text))
}