summaryrefslogtreecommitdiffstats
path: root/tpl/path/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/path/init.go')
-rw-r--r--tpl/path/init.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/tpl/path/init.go b/tpl/path/init.go
index ebfb59702..518dcad22 100644
--- a/tpl/path/init.go
+++ b/tpl/path/init.go
@@ -18,7 +18,6 @@ import (
"path/filepath"
"github.com/gohugoio/hugo/deps"
- "github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/tpl/internal"
)
@@ -41,11 +40,17 @@ func init() {
},
)
+ testDir := filepath.Join("my", "path")
+ testFile := filepath.Join(testDir, "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`},
+ {fmt.Sprintf(`{{ slice %q "filename.txt" | path.Join }}`, testDir), `my/path/filename.txt`},
{`{{ path.Join "my" "path" "filename.txt" }}`, `my/path/filename.txt`},
+ {fmt.Sprintf(`{{ %q | path.Ext }}`, testFile), `.txt`},
+ {fmt.Sprintf(`{{ %q | path.Base }}`, testFile), `filename.txt`},
+ {fmt.Sprintf(`{{ %q | path.Dir }}`, testFile), `my/path`},
},
)