Write writes the section to the given writer.
(w io.Writer)
| 119 | |
| 120 | // Write writes the section to the given writer. |
| 121 | func (s *SectionTemplate) Write(w io.Writer) error { |
| 122 | funcs := TemplateFuncs() |
| 123 | maps.Copy(funcs, s.FuncMap) |
| 124 | tmpl := template.Must(template.New(s.Name).Funcs(funcs).Parse(s.Source)) |
| 125 | return tmpl.Execute(w, s.Data) |
| 126 | } |
| 127 | |
| 128 | // finalizeGoSource processes Go source entirely in memory without file I/O |
| 129 | func finalizeGoSource(path string, content []byte) ([]byte, error) { |