Skip to content

Commit 2903afb

Browse files
Allow issue templates to not render title (#22589)
This adds a yaml attribute that will allow the option for when markdown is rendered that the title will be not included in the output Based on work from @brechtvl
1 parent 642db3c commit 2903afb

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

modules/issue/template/template.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
259259
}
260260

261261
// write label
262-
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
262+
if !f.HideLabel() {
263+
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
264+
}
263265

264266
blankPlaceholder := "_No response_\n"
265267

@@ -311,6 +313,13 @@ func (f *valuedField) Label() string {
311313
return ""
312314
}
313315

316+
func (f *valuedField) HideLabel() bool {
317+
if label, ok := f.Attributes["hide_label"].(bool); ok {
318+
return label
319+
}
320+
return false
321+
}
322+
314323
func (f *valuedField) Render() string {
315324
if render, ok := f.Attributes["render"].(string); ok {
316325
return render

modules/issue/template/template_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ body:
640640
description: Description of input
641641
placeholder: Placeholder of input
642642
value: Value of input
643+
hide_label: true
643644
validations:
644645
required: true
645646
is_number: true
@@ -681,8 +682,6 @@ body:
681682
682683
` + "```bash\nValue of id2\n```" + `
683684
684-
### Label of input
685-
686685
Value of id3
687686
688687
### Label of dropdown

0 commit comments

Comments
 (0)