commit f857f4caba4ab637f31d4ac46aad28c376aad752
parent d4caa8ee9571089b6b7d602fe744f786d7af9fee
Author: spf13 <steve.francia@gmail.com>
Date: Wed, 10 Jul 2013 17:57:28 -0400
adding helper to create absolute url
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/hugolib/helpers.go b/hugolib/helpers.go
@@ -22,6 +22,7 @@ import (
"regexp"
"strconv"
"strings"
+ "html/template"
"time"
)
@@ -147,6 +148,13 @@ func Urlize(url string) string {
return Sanitize(strings.ToLower(strings.Replace(strings.TrimSpace(url), " ", "-", -1)))
}
+func AbsUrl(url string, base string) template.HTML {
+ if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
+ return template.HTML(url)
+ }
+ return template.HTML(MakePermalink(base, url))
+}
+
func Gt(a interface{}, b interface{}) bool {
var left, right int64
av := reflect.ValueOf(a)