]> source.dussan.org Git - gitea.git/commitdiff
Allow issue templates to not render title (#22589)
authortechknowlogick <techknowlogick@gitea.io>
Fri, 27 Jan 2023 04:45:49 +0000 (23:45 -0500)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2023 04:45:49 +0000 (22:45 -0600)
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
modules/issue/template/template_test.go

index f8bce3f4651f436723137191726a21256a6f8618..0f19d87e8d5dcfe66501d2959d106907469147b0 100644 (file)
@@ -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
index 0845642cd39ceb2dd5d987589f8c4a2e91313373..0cdddd0c85f9d36bc913c7e233e8f663fae13b05 100644 (file)
@@ -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