mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 13:33:32 +02:00
templates: add wrap helper function
Add "wrap" command to TemplateProcessor. Use
github.com/mitchellh/go-wordwrap to wrap lines on word breaks at
a given length. This can make long fields much more readable in
a terminal. E.g.
{{ .fields.description | wrap 76 | indent 2}}
This commit is contained in:
committed by
Louis DeLosSantos
parent
6fbc522ee7
commit
0e3082fab6
@@ -21,6 +21,7 @@ import (
|
||||
shellquote "github.com/kballard/go-shellquote"
|
||||
"github.com/mgutz/ansi"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
wordwrap "github.com/mitchellh/go-wordwrap"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
@@ -191,6 +192,9 @@ func TemplateProcessor() *template.Template {
|
||||
"dateFormat": func(format string, content string) (string, error) {
|
||||
return dateFormat(format, content)
|
||||
},
|
||||
"wrap": func(width uint, content string) string {
|
||||
return wordwrap.WrapString(content, width)
|
||||
},
|
||||
}
|
||||
return template.New("gojira").Funcs(sprig.GenericFuncMap()).Funcs(funcs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user