Debian Codegraph @

docs/content/en/methods/shortcode/Name.md

raw
1 ---
2 title: Name
3 description: Returns the shortcode file name, excluding the file extension.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: string
9 signatures: [SHORTCODE.Name]
10 ---
11
12 The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
13
14 ```go-html-template {file="layouts/_shortcodes/myshortcode.html"}
15 {{ $greeting := "" }}
16 {{ with .Get "greeting" }}
17 {{ $greeting = . }}
18 {{ else }}
19 {{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }}
20 {{ end }}
21 ```
22
23 In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:
24
25 ```text
26 ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"
27 ```