code: func (t *Template) WriteTo(w io.Writer) (n int64, err error) {
  	var buf bytes.Buffer
  
  	// Write "generated" header comment.
  	buf.WriteString("// Generated by ego.\n")
  	buf.WriteString("// DO NOT EDIT\n\n")
  
  	// Write blocks.
  	writeBlocksTo(&buf, t.Blocks)
  
  	// Parse buffer as a Go file.
  	fset := token.NewFileSet()
  	f, err := parser.ParseFile(fset, "", buf.Bytes(), parser.ParseComments)
  	if err != nil {
  		n, _ = buf.WriteTo(w)
  		return n, err
  	}
  
  	// Inject required packages.
  	injectImports(f)
  
  	// Attempt to gofmt.
  	var result bytes.Buffer
  	if err := format.Node(&result, fset, f); err != nil {
  		n, _ = buf.WriteTo(w)
  		return n, err
  	}
  
  	// Write to output writer.
  	return result.WriteTo(w)
  }
docs: // WriteTo writes the template to a writer.