diff options
author | Joe Mooring <joe.mooring@veriphor.com> | 2023-04-14 13:27:16 -0700 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-19 10:31:17 +0200 |
commit | 5b3e165bad1318a1764ee534770fd2eda8a03feb (patch) | |
tree | 8abe6854567c6bb5ccda945982ad8d3dd51903fb /docs | |
parent | 03cb38e6c6d60e95df1f40a56fe432e1747ea7ac (diff) |
tpl/urls: Add JoinPath template function
See https://pkg.go.dev/net/url#JoinPath
Closes #9694
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/en/functions/urls.JoinPath.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/content/en/functions/urls.JoinPath.md b/docs/content/en/functions/urls.JoinPath.md new file mode 100644 index 000000000..c0e0464b6 --- /dev/null +++ b/docs/content/en/functions/urls.JoinPath.md @@ -0,0 +1,24 @@ +--- +title: urls.JoinPath +description: Joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. +categories: [functions] +menu: + docs: + parent: functions +keywords: [urls,path,join] +signature: ["urls.JoinPath ELEMENT..."] +--- + +```go-html-template +{{ urls.JoinPath "" }} → "/" +{{ urls.JoinPath "a" }} → "a" +{{ urls.JoinPath "a" "b" }} → "a/b" +{{ urls.JoinPath "/a" "b" }} → "/a/b" +{{ urls.JoinPath "https://example.org" "b" }} → "https://example.org/b" + +{{ urls.JoinPath (slice "a" "b") }} → "a/b" +``` + +Unlike the [`path.Join`] function, `urls.JoinPath` retains consecutive leading slashes. + +[`path.Join`]: /functions/path.join/ |