go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.11k stars 5.41k forks source link

Invalid HTML templates should fail to compile #31379

Open jtran opened 3 months ago

jtran commented 3 months ago

Feature Description

For a long time, I've wished that HTML templates would fail to compile when referencing a variable that doesn't exist or in other obviously wrong scenarios. Because of the way Gitea uses maps and template helpers now, this is currently not the case.

Could we switch to Templ? https://github.com/a-h/templ

I floated the idea in Gitea's Discord, and some people seemed interested.

I heard that maintainer sentiment is generally positive, but that was in 2023 and there were a few concerns:

I understand that this is a big undertaking. I'm opening the issue to have a place to put the conversation for anyone else thinking about a similar thing.

I apologize in advance if there's already another plan in place that I don't know about.

Screenshots

No response

lunny commented 3 months ago

Maybe not in compile, we can have a template test tool or sub-command to test whether the template will fail. I think this is an easier way to resolve the current problem. i.e. We can have a ./gitea doctor check-templates to check the templates. And changing the template system could be a long-term plan which can be discussed more.