shithub: hugo

Download patch

ref: f857f4caba4ab637f31d4ac46aad28c376aad752
parent: d4caa8ee9571089b6b7d602fe744f786d7af9fee
author: spf13 <[email protected]>
date: Wed Jul 10 13:57:28 EDT 2013

adding helper to create absolute url

--- a/hugolib/helpers.go
+++ b/hugolib/helpers.go
@@ -22,6 +22,7 @@
 	"regexp"
 	"strconv"
 	"strings"
+	"html/template"
 	"time"
 )
 
@@ -145,6 +146,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 {