Closed
Description
Feature Description
Gitea is heavily using Go HTML Template, so it's worth to make the template system more maintainable.
There are some strange smells in template/helper.go
:
- Deadcode clean up
-
Dict
/dict
/mergeinto
: actually we can have only one unique "dict"(map) maintaining function. - Many calculation related functions like
Add
,Mul
,percentage
, etc, they could be replaced by a more genericEval
like:{{Eval "(" $a "+" $b ")" "/" 100}}
-
Printf
vsprintf
: only builtinprintf
is enough - Iterate: it seems a little complex (removed by Improve Wiki TOC #24137)
- More and more functions need to use
Context
, it's better to introduce a general helper map or struct, then old code{{RenderEmoji $.Context ...}}
could be improved to{{.CtxFunc.RenderEmoji ...}}
- After Drop "unrolled/render" package #23965
- We can have per-request context global functions.
- Make HTML template functions support context #24056
- [Proposal] Make Gitea template system support context function #24228
-
containGeneric
vscontain
: clarify their behavior
TODO:
- Use
"SettingUI": &setting.UI
to expose all UI settings to templates
ps: only do big refactoring after 1.19.0 or even 1.19.1 gets released, to prevent from making backport difficult.