From 2903afb78f77ed94c0515a6e58e27c23a13f2671 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Thu, 26 Jan 2023 23:45:49 -0500 Subject: 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 --- modules/issue/template/template.go | 11 ++++++++++- modules/issue/template/template_test.go | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/issue/template/template.go b/modules/issue/template/template.go index f8bce3f465..0f19d87e8d 100644 --- a/modules/issue/template/template.go +++ b/modules/issue/template/template.go @@ -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" @@ -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 diff --git a/modules/issue/template/template_test.go b/modules/issue/template/template_test.go index 0845642cd3..0cdddd0c85 100644 --- a/modules/issue/template/template_test.go +++ b/modules/issue/template/template_test.go @@ -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 @@ -681,8 +682,6 @@ body: ` + "```bash\nValue of id2\n```" + ` -### Label of input - Value of id3 ### Label of dropdown -- cgit v1.2.3