diff options
author | Jimmy Praet <jimmy.praet@ksz-bcss.fgov.be> | 2020-12-03 11:50:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 11:50:47 +0100 |
commit | 056b8f5b52fc0e9ab32f99c016e1ee28975c4bcd (patch) | |
tree | 143cc94f5ded3ec1897bd509e30351149c691170 /modules/templates | |
parent | 18712eab791fe3c4cd6fa959eb1ab4b75c935cb3 (diff) | |
download | gitea-056b8f5b52fc0e9ab32f99c016e1ee28975c4bcd.tar.gz gitea-056b8f5b52fc0e9ab32f99c016e1ee28975c4bcd.zip |
Clickable links in pull request (and issue) titles (#13695)
* clickable links in pull request (and issue) titles #13658
reuses the existing logic to render clickable links in commit messages
* dedicated RenderIssueTitle function
applied patch from @mrsdizzie
Diffstat (limited to 'modules/templates')
-rw-r--r-- | modules/templates/helper.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index bb7a3476f2..8b96397529 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -154,6 +154,7 @@ func NewFuncMap() []template.FuncMap { "RenderCommitMessageLink": RenderCommitMessageLink, "RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject, "RenderCommitBody": RenderCommitBody, + "RenderIssueTitle": RenderIssueTitle, "RenderEmoji": RenderEmoji, "RenderEmojiPlain": emoji.ReplaceAliases, "ReactionToEmoji": ReactionToEmoji, @@ -630,6 +631,16 @@ func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.H return template.HTML(renderedMessage) } +// RenderIssueTitle renders issue/pull title with defined post processors +func RenderIssueTitle(text, urlPrefix string, metas map[string]string) template.HTML { + renderedText, err := markup.RenderIssueTitle([]byte(template.HTMLEscapeString(text)), urlPrefix, metas) + if err != nil { + log.Error("RenderIssueTitle: %v", err) + return template.HTML("") + } + return template.HTML(renderedText) +} + // RenderEmoji renders html text with emoji post processors func RenderEmoji(text string) template.HTML { renderedText, err := markup.RenderEmoji([]byte(template.HTMLEscapeString(text))) |