Skip to content

Commit

Permalink
Allow issue templates to not render title (#22589)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
techknowlogick authored Jan 27, 2023
1 parent 642db3c commit 2903afb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion modules/issue/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
}

// write label
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
if !f.HideLabel() {
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
}

blankPlaceholder := "_No response_\n"

Expand Down Expand Up @@ -311,6 +313,13 @@ func (f *valuedField) Label() string {
return ""
}

func (f *valuedField) HideLabel() bool {
if label, ok := f.Attributes["hide_label"].(bool); ok {
return label
}
return false
}

func (f *valuedField) Render() string {
if render, ok := f.Attributes["render"].(string); ok {
return render
Expand Down
3 changes: 1 addition & 2 deletions modules/issue/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ body:
description: Description of input
placeholder: Placeholder of input
value: Value of input
hide_label: true
validations:
required: true
is_number: true
Expand Down Expand Up @@ -681,8 +682,6 @@ body:
` + "```bash\nValue of id2\n```" + `
### Label of input
Value of id3
### Label of dropdown
Expand Down

0 comments on commit 2903afb

Please sign in to comment.