tpl/path: Add path.Join

This commit is contained in:
Bjørn Erik Pedersen
2018-04-15 21:06:57 +02:00
parent 01b72eb592
commit 880ca19f20
2 changed files with 46 additions and 0 deletions

View File

@@ -14,7 +14,11 @@
package path
import (
"fmt"
"path/filepath"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/tpl/internal"
)
@@ -33,6 +37,15 @@ func init() {
nil,
[][2]string{
{`{{ "/my/path/filename.txt" | path.Split }}`, `/my/path/|filename.txt`},
{fmt.Sprintf(`{{ %q | path.Split }}`, filepath.FromSlash("/my/path/filename.txt")), `/my/path/|filename.txt`},
},
)
ns.AddMethodMapping(ctx.Join,
nil,
[][2]string{
{fmt.Sprintf(`{{ slice %q "filename.txt" | path.Join }}`, "my"+helpers.FilePathSeparator+"path"), `my/path/filename.txt`},
{`{{ path.Join "my" "path" "filename.txt" }}`, `my/path/filename.txt`},
},
)