Skip to content

Commit 027adee

Browse files
AdrianoAdriano Caloiaro
authored andcommitted
Add 'pctOf' and 'fit' template functions
1 parent b8e73a5 commit 027adee

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

jiracli/templates.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func TemplateProcessor() *template.Template {
7676
}
7777
return out
7878
},
79+
"fit": func(size int, content string) string {
80+
return fmt.Sprintf(fmt.Sprintf("%%-%d.%ds", size, size), content)
81+
},
7982
"shellquote": func(content string) string {
8083
return shellquote.Join(content)
8184
},
@@ -106,6 +109,9 @@ func TemplateProcessor() *template.Template {
106109
}
107110
return 120
108111
},
112+
"pctOf": func(size, percent int) int {
113+
return int(float32(size) * (float32(percent) / 100))
114+
},
109115
"sub": func(a, b int) int {
110116
return a - b
111117
},
@@ -354,7 +360,7 @@ const defaultEditTemplate = `{{/* edit template */ -}}
354360
# issue: {{ .key }} - created: {{ .fields.created | age}} ago
355361
update:
356362
comment:
357-
- add:
363+
- add:
358364
body: |~
359365
{{ or .overrides.comment "" | indent 10 }}
360366
fields:
@@ -484,7 +490,7 @@ const defaultTransitionTemplate = `{{/* transition template */ -}}
484490
{{- if .meta.fields.comment }}
485491
update:
486492
comment:
487-
- add:
493+
- add:
488494
body: |~
489495
{{ or .overrides.comment "" | indent 10 }}
490496
{{- end -}}

0 commit comments

Comments
 (0)