in internal/changelog/fragment/template.go [17:39]
func Template(slug string) ([]byte, error) {
data, err := template.ReadFile("template.yaml")
if err != nil {
return nil, fmt.Errorf("cannot read embedded template: %w", err)
}
tmpl, err := txttempl.New("template").Parse(string(data))
if err != nil {
return nil, fmt.Errorf("cannot parse template: %w", err)
}
vars := make(map[string]interface{})
vars["Summary"] = slug
buf := bytes.NewBuffer(nil)
err = tmpl.Execute(buf, vars)
if err != nil {
return nil, fmt.Errorf("cannot execute template: %w", err)
}
return buf.Bytes(), nil
}