commit 0ba9fb9631f6f97ae50929006937b540b1ff8a37
parent ba8a00a6f98650340457d79927352dc542001bba
Author: digitalcraftsman <digitalcraftsman@protonmail.com>
Date: Sat, 3 Dec 2016 20:12:12 +0100
docs: Document querify template func
Closes #2733
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/docs/content/templates/functions.md b/docs/content/templates/functions.md
@@ -880,6 +880,16 @@ Takes a string and sanitizes it for usage in URLs, converts spaces to "-".
e.g. `<a href="/tags/{{ . | urlize }}">{{ . }}</a>`
+### querify
+
+Takes a set of key-value pairs and returns a [`url.Values`](https://godoc.org/net/url#Values) object. The [`Encode`](https://godoc.org/net/url#Values.Encode) method turns the pairs into a [query string](https://en.wikipedia.org/wiki/Query_string) that cen be postpended to a url. E.g.
+
+ <a href="https://www.google.com?{{ (querify "q" "test" "page" 3).Encode | safeHTML }}">Search</a>
+
+will be rendered as
+
+ <a href="https://www.google.com?page=3&q=test">Search</a>
+
## Content Views