mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
This commit is contained in:
@@ -11,21 +11,21 @@ action:
|
||||
signatures: [SHORTCODE.Position]
|
||||
---
|
||||
|
||||
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter:
|
||||
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
|
||||
|
||||
{{< code file=layouts/shortcodes/myshortcode.html >}}
|
||||
{{ $greeting := "" }}
|
||||
{{ with .Get "greeting" }}
|
||||
{{ $greeting = . }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode requires a 'greeting' parameter. See %s" .Name .Position }}
|
||||
{{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }}
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
||||
In the absence of a "greeting" parameter, Hugo will throw an error message and fail the build:
|
||||
In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:
|
||||
|
||||
```text
|
||||
ERROR The "myshortcode" shortcode requires a 'greeting' parameter. See "/home/user/project/content/about.md:11:1"
|
||||
ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
Reference in New Issue
Block a user