blob: 4c4340a097de60d92f26d708568719f6e6253700 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
---
title: path.BaseName
description: Replaces path separators with slashes (`/`) and returns the last element of the given path, removing the extension if present.
categories: []
keywords: []
action:
aliases: []
related:
- functions/path/Base
- functions/path/Clean
- functions/path/Dir
- functions/path/Ext
- functions/path/Join
- functions/path/Split
returnType: string
signatures: [path.BaseName PATH]
aliases: [/functions/path.basename]
---
{{< new-in 0.101.0 >}}
```go-html-template
{{ path.BaseName "a/news.html" }} → news
{{ path.BaseName "news.html" }} → news
{{ path.BaseName "a/b/c" }} → c
{{ path.BaseName "/x/y/z/" }} → z
{{ path.BaseName "" }} → .
```
|