diff options
author | techknowlogick <techknowlogick@gitea.io> | 2023-01-26 23:45:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 22:45:49 -0600 |
commit | 2903afb78f77ed94c0515a6e58e27c23a13f2671 (patch) | |
tree | 414c2957fe25c221bce9fe432fc4c6b844e321d7 | |
parent | 642db3c8f7d2faf9ff02867cf1e1287fa0e1d593 (diff) | |
download | gitea-2903afb78f77ed94c0515a6e58e27c23a13f2671.tar.gz gitea-2903afb78f77ed94c0515a6e58e27c23a13f2671.zip |
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
-rw-r--r-- | modules/issue/template/template.go | 11 | ||||
-rw-r--r-- | 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 |