path.Base

将以下英文翻译为中文:

path.Base

https://gohugo.io/functions/path.base/

Base returns the last element of a path.

语法

path.Base PATH

path.Base returns the last element of PATH.

If PATH is empty, . is returned.

Note: On Windows, PATH is converted to slash (/) separators.

1
2
3
4
{{ path.Base "a/news.html" }} → "news.html"
{{ path.Base "news.html" }} → "news.html"
{{ path.Base "a/b/c" }} → "c"
{{ path.Base "/x/y/z/" }} → "z"

另请参阅