summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/shortcode/Position.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/methods/shortcode/Position.md')
-rw-r--r--docs/content/en/methods/shortcode/Position.md21
1 files changed, 9 insertions, 12 deletions
diff --git a/docs/content/en/methods/shortcode/Position.md b/docs/content/en/methods/shortcode/Position.md
index 6f047c01b..24810e825 100644
--- a/docs/content/en/methods/shortcode/Position.md
+++ b/docs/content/en/methods/shortcode/Position.md
@@ -1,26 +1,24 @@
---
title: Position
-description: Returns the filename and position from which the shortcode was called.
+description: Returns the file name and position from which the shortcode was called.
categories: []
keywords: []
-action:
- related:
- - methods/shortcode/Name
- - functions/fmt/Errorf
- returnType: text.Position
- signatures: [SHORTCODE.Position]
+params:
+ functions_and_methods:
+ returnType: text.Position
+ signatures: [SHORTCODE.Position]
---
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
-{{< code file=layouts/shortcodes/myshortcode.html >}}
+```go-html-template {file="layouts/shortcodes/myshortcode.html"}
{{ $greeting := "" }}
{{ with .Get "greeting" }}
{{ $greeting = . }}
{{ else }}
{{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }}
{{ end }}
-{{< /code >}}
+```
In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:
@@ -28,6 +26,5 @@ In the absence of a "greeting" argument, Hugo will throw an error message and fa
ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"
```
-{{% note %}}
-The position can be expensive to calculate. Limit its use to error reporting.
-{{% /note %}}
+> [!note]
+> The position can be expensive to calculate. Limit its use to error reporting.