CV/helpers/templatefuncs.go
Dan Anglin 700f009f53
refactor: integrate tex generator into mage
This commit integrates the Tex generator functionality from main.go into
the mage system. Changes include:

- Movd helper functions to the new helpers package.
- Move the tex generator from main.go to the helpers package.
- Update the Tex target to use the tex generator helper function.
2020-09-12 14:06:28 +01:00

34 lines
751 B
Go

package helpers
import (
"fmt"
"strings"
)
// notLastElement returns true if an element of an array
// or a slice is not the last.
func notLastElement(pos, length int) bool {
return pos < length-1
}
// join uses strings.Join to join all string elements into
// a single string.
func join(s []string) string {
return strings.Join(s, " ")
}
// durationToString outputs the employment/education
// duration as a formatted string.
func durationToString(d Duration) string {
start := fmt.Sprintf("%s, %s", d.Start.Month, d.Start.Year)
present := strings.ToLower(d.Present)
end := ""
if present == "yes" || present == "true" {
end = "Present"
} else {
end = fmt.Sprintf("%s, %s", d.End.Month, d.End.Year)
}
return start + " - " + end
}