diff --git a/sv/formatter.go b/sv/formatter.go index 96e8488..61b7ee8 100644 --- a/sv/formatter.go +++ b/sv/formatter.go @@ -34,7 +34,7 @@ type OutputFormatterImpl struct { func NewOutputFormatter(templatesFS fs.FS) *OutputFormatterImpl { templateFNs := map[string]interface{}{ "timefmt": timeFormat, - "getSection": getSection, + "getsection": getSection, } tpls := template.Must(template.New("templates").Funcs(templateFNs).ParseFS(templatesFS, "*")) return &OutputFormatterImpl{templates: tpls} @@ -88,19 +88,3 @@ func toSortedArray(input map[string]struct{}) []string { sort.Strings(result) return result } - -func timeFormat(t time.Time, format string) string { - if t.IsZero() { - return "" - } - return t.Format(format) -} - -func getSection(sections []ReleaseNoteSection, name string) ReleaseNoteSection { - for _, section := range sections { - if section.SectionName() == name { - return section - } - } - return nil -} diff --git a/sv/formatter_functions.go b/sv/formatter_functions.go new file mode 100644 index 0000000..607b988 --- /dev/null +++ b/sv/formatter_functions.go @@ -0,0 +1,19 @@ +package sv + +import "time" + +func timeFormat(t time.Time, format string) string { + if t.IsZero() { + return "" + } + return t.Format(format) +} + +func getSection(sections []ReleaseNoteSection, name string) ReleaseNoteSection { + for _, section := range sections { + if section.SectionName() == name { + return section + } + } + return nil +}