Add a 'join' func to the template engine

I needed this so that I can display JIRA labels in my 'list' template.
This commit is contained in:
Mike Pountney
2015-12-23 06:15:31 -08:00
parent bc70b43868
commit d4f15ae5c6
+7
View File
@@ -161,6 +161,13 @@ func runTemplate(templateContent string, data interface{}, out io.Writer) error
"split": func(sep string, content string) []string {
return strings.Split(content, sep)
},
"join": func(sep string, content []interface{}) string {
vals := make([]string, len(content))
for i, v := range content {
vals[i] = v.(string)
}
return strings.Join(vals, sep)
},
"abbrev": func(max int, content string) string {
if len(content) > max {
var buffer bytes.Buffer