Skip to content

Commit

Permalink
Add a 'join' func to the template engine
Browse files Browse the repository at this point in the history
I needed this so that I can display JIRA labels in my 'list' template.
  • Loading branch information
Mike Pountney committed Dec 23, 2015
1 parent 7268b9e commit a7820fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7820fe

Please sign in to comment.