diff options
Diffstat (limited to 'pkg/html/html.go')
| -rw-r--r-- | pkg/html/html.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/html/html.go b/pkg/html/html.go index c7f85da88..e985ae977 100644 --- a/pkg/html/html.go +++ b/pkg/html/html.go @@ -32,6 +32,7 @@ func CreateGlob(glob string) *template.Template { } var funcs = template.FuncMap{ + "link": link, "formatTime": FormatTime, "formatClock": formatClock, "formatDuration": formatDuration, @@ -41,6 +42,14 @@ var funcs = template.FuncMap{ "formatShortHash": formatShortHash, } +func link(url, text string) template.HTML { + text = template.HTMLEscapeString(text) + if url != "" { + text = fmt.Sprintf(`<a href="%v">%v</a>`, url, text) + } + return template.HTML(text) +} + func FormatTime(t time.Time) string { if t.IsZero() { return "" |
