hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 39fe42cf6b0032712e2fa97f86accd4a29ad9d24
parent fbf48824aeab6833c1550d9e6bf1b99c3d84cb75
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Wed,  6 Jul 2016 20:57:37 +0200

Simplify querify

Diffstat:
Mtpl/template_funcs.go | 8++++----
Mtpl/template_funcs_test.go | 2+-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go
@@ -1746,19 +1746,19 @@ func sha1(in interface{}) (string, error) {
 	return hex.EncodeToString(hash[:]), nil
 }
 
-// querify converts the given parameters into a url.Values object
-func querify(params ...interface{}) (url.Values, error) {
+// querify encodes the given parameters  “URL encoded” form ("bar=baz&foo=quux") sorted by key.
+func querify(params ...interface{}) (string, error) {
 	qs := url.Values{}
 	vals, err := dictionary(params...)
 	if err != nil {
-		return url.Values{}, fmt.Errorf("querify keys must be strings")
+		return "", fmt.Errorf("querify keys must be strings")
 	}
 
 	for name, value := range vals {
 		qs.Add(name, url.QueryEscape(fmt.Sprintf("%v", value)))
 	}
 
-	return qs, nil
+	return qs.Encode(), nil
 }
 
 func init() {
diff --git a/tpl/template_funcs_test.go b/tpl/template_funcs_test.go
@@ -103,7 +103,7 @@ modBool: {{modBool 15 3}}
 mul: {{mul 2 3}}
 plainify: {{ plainify  "Hello <strong>world</strong>, gophers!" }}
 pluralize: {{ "cat" | pluralize }}
-querify: {{ (querify "foo" 1 "bar" 2 "baz" "with spaces").Encode | safeHTML }}
+querify: {{ (querify "foo" 1 "bar" 2 "baz" "with spaces") | safeHTML }}
 readDir: {{ range (readDir ".") }}{{ .Name }}{{ end }}
 readFile: {{ readFile "README.txt" }}
 relURL 1: {{ "http://gohugo.io/" | relURL }}