Refactor large templates #513

Closed
opened 2025-11-02 03:26:17 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @bkcsoft on GitHub (Mar 15, 2017).

Description

As of e83c8afc56 a lot of templates are huge (over 100 lines) and some are only added to ad infinitum without any checks. Templates are one of these things that can be broken down quite easily. IMO this should be done (I'll start with a few so I'm not just pointing fingers 😛 )

List of templates that are huge (200loc+) and a quick thought on how to refactor

  • 444 repo/issue/view_content.tmpl #1276
    Start by splitting range .Issue.Comments and go from there
  • 393 repo/settings/options.tmpl
    Not as easy, I'd suggest looking at Vue :trollface:
  • 354 home.tmpl
    Just a bunch of translations for no apparent reason...
  • 281 admin/config.tmpl
    Vue?
  • 260 install.tmpl
    Not that much that can be done...
  • 211 admin/auth/edit.tmpl
    Easy, it's a long list of if-statements that can be broken out
  • 209 base/head.tmpl
    Split out the big if .IsSigned-block
  • 205 admin/auth/new.tmpl #1277
    Split on auth-method

List of less prioritized files (100=>200 loc) that I didn't bother looking into

These don't make much sense to refactor, 150 loc isn't that much really... At least until we start moving things into Vue-Modules :trollface:

  • 157 repo/issue/labels.tmpl
  • 156 repo/issue/list.tmpl
  • 155 repo/diff/box.tmpl
  • 135 user/dashboard/dashboard.tmpl
  • 134 repo/issue/milestones.tmpl
  • 132 admin/user/edit.tmpl
  • 125 admin/dashboard.tmpl
  • 121 repo/issue/new_form.tmpl
  • 116 repo/create.tmpl
  • 113 user/notification/notification.tmpl
  • 112 user/dashboard/issues.tmpl
  • 109 repo/release/new.tmpl
  • 108 user/profile.tmpl
  • 107 repo/header.tmpl
  • 104 repo/wiki/view.tmpl
  • 104 admin/notice.tmpl
  • 101 repo/migrate.tmpl

Any thoughts?

Originally created by @bkcsoft on GitHub (Mar 15, 2017). - Gitea version (or commit ref): e83c8afc56c028bddba5074fb945cb0b7c45d32b ## Description As of e83c8afc56c028bddba5074fb945cb0b7c45d32b a lot of templates are *huge* (over 100 lines) and some are only added to ad infinitum without any checks. Templates are one of these things that can be broken down quite easily. IMO this should be done (I'll start with a few so I'm not just pointing fingers 😛 ) ### List of templates that are huge (200loc+) and a quick thought on how to refactor - [x] 444 repo/issue/view_content.tmpl #1276 Start by splitting `range .Issue.Comments` and go from there - [ ] 393 repo/settings/options.tmpl Not as easy, I'd suggest looking at Vue :trollface: - [ ] 354 home.tmpl Just a bunch of translations for no apparent reason... - [ ] 281 admin/config.tmpl Vue? - [ ] 260 install.tmpl Not that much that can be done... - [ ] 211 admin/auth/edit.tmpl Easy, it's a long list of if-statements that can be broken out - [ ] 209 base/head.tmpl Split out the big `if .IsSigned`-block - [x] 205 admin/auth/new.tmpl #1277 Split on auth-method ### ~List of less prioritized files (100=>200 loc) that I didn't bother looking into~ ### These don't make much sense to refactor, 150 loc isn't that much really... At least until we start moving things into Vue-Modules :trollface: - [ ] 157 repo/issue/labels.tmpl - [ ] 156 repo/issue/list.tmpl - [ ] 155 repo/diff/box.tmpl - [ ] 135 user/dashboard/dashboard.tmpl - [ ] 134 repo/issue/milestones.tmpl - [ ] 132 admin/user/edit.tmpl - [ ] 125 admin/dashboard.tmpl - [ ] 121 repo/issue/new_form.tmpl - [ ] 116 repo/create.tmpl - [ ] 113 user/notification/notification.tmpl - [ ] 112 user/dashboard/issues.tmpl - [ ] 109 repo/release/new.tmpl - [ ] 108 user/profile.tmpl - [ ] 107 repo/header.tmpl - [ ] 104 repo/wiki/view.tmpl - [ ] 104 admin/notice.tmpl - [ ] 101 repo/migrate.tmpl Any thoughts?
GiteaMirror added the type/refactoringtype/summary labels 2025-11-02 03:26:17 -06:00
Author
Owner

@strk commented on GitHub (Mar 16, 2017):

One thought: custom templates would be broken every time we change templates, so if it needs to be done, let's do it once in a way to reduce further changes.
Another thing: what is Vue ? :)

@strk commented on GitHub (Mar 16, 2017): One thought: custom templates would be broken every time we change templates, so if it needs to be done, let's do it once in a way to reduce further changes. Another thing: what is Vue ? :)
Author
Owner

@andreynering commented on GitHub (Mar 16, 2017):

http://vuejs.org

@andreynering commented on GitHub (Mar 16, 2017): http://vuejs.org
Author
Owner

@bkcsoft commented on GitHub (Apr 18, 2017):

@strk not exactly, I haven't (and won't be for the time being) changed the data-format, only broken down template-files, so all custom templates should still be fine. Breaking them down actually makes it easier to maintain custom templates since they are now smaller and more focused around one thing only 🙂

@bkcsoft commented on GitHub (Apr 18, 2017): @strk not exactly, I haven't (and won't be for the time being) changed the data-format, only broken down template-files, so all custom templates should still be fine. Breaking them down actually makes it easier to maintain custom templates since they are now smaller and more focused around one thing only 🙂
Author
Owner

@strk commented on GitHub (Apr 18, 2017):

@bkcsoft got it: so this is just adding more templates, basically, while still allowing using the parent for a single override. Great move !

@strk commented on GitHub (Apr 18, 2017): @bkcsoft got it: so this is just *adding* more templates, basically, while still allowing using the parent for a single override. Great move !
Author
Owner

@lunny commented on GitHub (Sep 11, 2023):

Close as many templates changed and this is outdated.

@lunny commented on GitHub (Sep 11, 2023): Close as many templates changed and this is outdated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#513