From e71eb8930a5d0f60874b038c223498b41ad65592 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 1 Mar 2024 15:11:51 +0800 Subject: Refactor some Str2html code (#29397) This PR touches the most interesting part of the "template refactoring". 1. Unclear variable type. Especially for "web/feed/convert.go": sometimes it uses text, sometimes it uses HTML. 2. Assign text content to "RenderedContent" field, for example: ` project.RenderedContent = project.Description` in web/org/projects.go 3. Assign rendered content to text field, for example: `r.Note = rendered content` in web/repo/release.go 4. (possible) Incorrectly calling `{{Str2html .PackageDescriptor.Metadata.ReleaseNotes}}` in package/content/nuget.tmpl, I guess the name Str2html misleads developers to use it to "render string to html", but it only sanitizes. if ReleaseNotes really contains HTML, then this is not a problem. --- templates/mail/release.tmpl | 2 +- templates/org/header.tmpl | 2 +- templates/org/home.tmpl | 2 +- templates/package/content/nuget.tmpl | 2 +- templates/projects/list.tmpl | 2 +- templates/projects/view.tmpl | 2 +- templates/repo/diff/comments.tmpl | 2 +- templates/repo/issue/milestone_issues.tmpl | 2 +- templates/repo/issue/milestones.tmpl | 2 +- templates/repo/issue/view_content.tmpl | 2 +- templates/repo/issue/view_content/attachments.tmpl | 4 ++-- templates/repo/issue/view_content/comments.tmpl | 6 +++--- templates/repo/issue/view_content/conversation.tmpl | 2 +- templates/repo/release/list.tmpl | 2 +- templates/shared/user/profile_big_avatar.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 2 +- templates/user/profile.tmpl | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) (limited to 'templates') diff --git a/templates/mail/release.tmpl b/templates/mail/release.tmpl index 62a16573c6..90a3caa4c5 100644 --- a/templates/mail/release.tmpl +++ b/templates/mail/release.tmpl @@ -22,7 +22,7 @@ {{.locale.Tr "mail.release.note"}} {{- if eq .Release.RenderedNote ""}} {{else}} - {{.Release.RenderedNote | Str2html}} + {{.Release.RenderedNote}} {{end -}}