Skip to content

Commit

Permalink
Merge pull request #20 from mikepea/add_join_template_func
Browse files Browse the repository at this point in the history
Add a 'join' func to the template engine
  • Loading branch information
coryb committed Dec 23, 2015
2 parents 7268b9e + a7820fe commit 425b571
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 425b571

Please sign in to comment.