diff options
Diffstat (limited to 'modules/templates/helper.go')
-rw-r--r-- | modules/templates/helper.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 24a383252b..098a642556 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -125,6 +125,7 @@ func NewFuncMap() []template.FuncMap { "RenderCommitMessage": RenderCommitMessage, "RenderCommitMessageLink": RenderCommitMessageLink, "RenderCommitBody": RenderCommitBody, + "RenderNote": RenderNote, "IsMultilineCommitMessage": IsMultilineCommitMessage, "ThemeColorMetaTag": func() string { return setting.UI.ThemeColorMetaTag @@ -392,6 +393,17 @@ func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.H return template.HTML(strings.Join(body[1:], "\n")) } +// RenderNote renders the contents of a git-notes file as a commit message. +func RenderNote(msg, urlPrefix string, metas map[string]string) template.HTML { + cleanMsg := template.HTMLEscapeString(msg) + fullMessage, err := markup.RenderCommitMessage([]byte(cleanMsg), urlPrefix, "", metas) + if err != nil { + log.Error("RenderNote: %v", err) + return "" + } + return template.HTML(string(fullMessage)) +} + // IsMultilineCommitMessage checks to see if a commit message contains multiple lines. func IsMultilineCommitMessage(msg string) bool { return strings.Count(strings.TrimSpace(msg), "\n") >= 1 |