Thanks Nathan. I'm still confused.
>* ParseFiles adds a new template to the collection with the filename as its name* So if my MyTempl was named "tf1", calling MyTempl.ParseFiles() with more than one files will have new templates created according to each of the passed filename? Or the template name never changes regardless how many files are passed in `ParseFiles()`? I.e., for MyTempl := tt.New("tf1") MyTempl.ParseFiles("tf1") MyTempl.ParseFiles("tf1","tf2") Would MyTempl have different template names after above each statement? If so, then which one does the `MyTempl.Execute()` uses? On Thursday, July 6, 2017 at 1:49:54 PM UTC-4, Nathan Kerr wrote: > > A text.Template contains one or more named templates. ParseFiles adds a > new template to the collection with the filename as its name. Template > names are used to tell Template.ExecuteTemplate > <https://godoc.org/text/template#Template.ExecuteTemplate> which of the > included templates to execute. > > On Thursday, July 6, 2017 at 6:37:01 AM UTC+2, Tong Sun wrote: >> >> What would it happen if I pass two or more files to: >> >> func (*Template) ParseFiles >> <https://golang.org/src/text/template/helper.go#L52> >> ❖ <https://golang.org/src/text/template/helper.go#L52> >> >> func (t *Template <http://godoc.org/text/template#Template>) >> ParseFiles(filenames ...string <http://godoc.org/builtin#string>) (*Template >> <http://godoc.org/text/template#Template>, error >> <http://godoc.org/builtin#error>) >> >> ParseFiles parses the named files and associates the resulting templates >> with t. If an error occurs, parsing stops and the returned template is nil; >> otherwise it is t. There must be at least one file. Since the templates >> created by ParseFiles are named by the base names of the argument files, t >> should usually have the name of one of the (base) names of the files. If it >> does not, depending on t's contents before calling ParseFiles, t.Execute >> may fail. In that case use t.ExecuteTemplate to execute a valid template. >> >> When parsing multiple files with the same name in different directories, >> the last one mentioned will be the one that results. >> >> E.g., >> >> What would the differences be that affects the output, for >> >> MyTempl.ParseFiles(tf1) >> >> vs. >> >> MyTempl.ParseFiles(tf1,tf2)? >> >> Will the content of tf2 be appended to tf1? >> >> Thx >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.