Skip to content

Mail templates are not hot loaded in the dev mode #27862

Open
@lng2020

Description

@lng2020

Description

The problem is mail package defines a package variable template.

var (
	bodyTemplates       *template.Template
	subjectTemplates    *texttmpl.Template
)

If a mail is sent already, which means this template invokes the Execute method. Then change the mail template, the same template invokes the Parse method. But the current html/template package of Go doesn't allow Parse after Execute, so this bug occurs.
Probably we should refactor the mail render method to align our current HTML render. However, I failed to do so because the syntax of the mail template is slightly different from the go template. So the current newScopedTemplateSet can't handle those mail templates. I don't know if I should change the mail template syntax or if there is another workaround.
cc @wxiaoguang

Gitea Version

latest codebase

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

built from source

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementAn improvement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions