Skip to content

Commit

Permalink
Add 'pctOf' and 'fit' template functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano authored and Adriano Caloiaro committed Aug 25, 2019
1 parent b8e73a5 commit 027adee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions jiracli/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func TemplateProcessor() *template.Template {
}
return out
},
"fit": func(size int, content string) string {
return fmt.Sprintf(fmt.Sprintf("%%-%d.%ds", size, size), content)
},
"shellquote": func(content string) string {
return shellquote.Join(content)
},
Expand Down Expand Up @@ -106,6 +109,9 @@ func TemplateProcessor() *template.Template {
}
return 120
},
"pctOf": func(size, percent int) int {
return int(float32(size) * (float32(percent) / 100))
},
"sub": func(a, b int) int {
return a - b
},
Expand Down Expand Up @@ -354,7 +360,7 @@ const defaultEditTemplate = `{{/* edit template */ -}}
# issue: {{ .key }} - created: {{ .fields.created | age}} ago
update:
comment:
- add:
- add:
body: |~
{{ or .overrides.comment "" | indent 10 }}
fields:
Expand Down Expand Up @@ -484,7 +490,7 @@ const defaultTransitionTemplate = `{{/* transition template */ -}}
{{- if .meta.fields.comment }}
update:
comment:
- add:
- add:
body: |~
{{ or .overrides.comment "" | indent 10 }}
{{- end -}}
Expand Down

0 comments on commit 027adee

Please sign in to comment.