mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-21 22:10:39 +00:00
parent
79df6b030f
commit
7871515ac0
@ -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
|
||||
}
|
||||
|
19
sv/formatter_functions.go
Normal file
19
sv/formatter_functions.go
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user