diff options
Diffstat (limited to 'docs/content/en/methods/shortcode')
-rw-r--r-- | docs/content/en/methods/shortcode/Ordinal.md | 4 | ||||
-rw-r--r-- | docs/content/en/methods/shortcode/Scratch.md | 12 | ||||
-rw-r--r-- | docs/content/en/methods/shortcode/Store.md | 29 |
3 files changed, 44 insertions, 1 deletions
diff --git a/docs/content/en/methods/shortcode/Ordinal.md b/docs/content/en/methods/shortcode/Ordinal.md index 6f3580d0f..41393fa22 100644 --- a/docs/content/en/methods/shortcode/Ordinal.md +++ b/docs/content/en/methods/shortcode/Ordinal.md @@ -11,6 +11,10 @@ action: The `Ordinal` method returns the zero-based ordinal of the shortcode in relation to its parent. If the parent is the page itself, the ordinal represents the position of this shortcode in the page content. +{{% note %}} +Hugo increments the ordinal with each shortcode call, regardless of the specific shortcode type. This means that the ordinal value is tracked sequentially across all shortcodes within a given page. +{{% /note %}} + This method is useful for, among other things, assigning unique element IDs when a shortcode is called two or more times from the same page. For example: {{< code file=content/about.md lang=md >}} diff --git a/docs/content/en/methods/shortcode/Scratch.md b/docs/content/en/methods/shortcode/Scratch.md index fcfc99d53..811d9f9ee 100644 --- a/docs/content/en/methods/shortcode/Scratch.md +++ b/docs/content/en/methods/shortcode/Scratch.md @@ -10,7 +10,17 @@ action: signatures: [SHORTCODE.Scratch] --- -The `Scratch` method within a shortcode creates a [scratch pad] to store and manipulate data. The scratch pad is scoped to the shortcode, and is reset on server rebuilds. +{{% deprecated-in 0.139.0 %}} +Use the [`SHORTCODE.Store`] method instead. + +This is a soft deprecation. This method will be removed in a future release, but the removal date has not been established. Although Hugo will not emit a warning if you continue to use this method, you should begin using `SHORTCODE.Store` as soon as possible. + +Beginning with v0.139.0 the `SHORTCODE.Scratch` method is aliased to `SHORTCODE.Store`. + +[`SHORTCODE.Store`]: /methods/shortcode/store/ +{{% /deprecated-in %}} + +The `Scratch` method within a shortcode creates a [scratch pad] to store and manipulate data. The scratch pad is scoped to the shortcode. {{% note %}} With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Scratch` method within a shortcode is obsolete. diff --git a/docs/content/en/methods/shortcode/Store.md b/docs/content/en/methods/shortcode/Store.md new file mode 100644 index 000000000..f7be8c8d0 --- /dev/null +++ b/docs/content/en/methods/shortcode/Store.md @@ -0,0 +1,29 @@ +--- +title: Store +description: Returns a "Store pad" scoped to the shortcode to store and manipulate data. +categories: [] +keywords: [] +action: + related: + - functions/collections/NewScratch + - methods/page/Store + - methods/site/Store + - functions/hugo/Store + returnType: maps.Store + signatures: [SHORTCODE.Store] +--- + +{{< new-in 0.139.0 >}} + +The `Store` method within a shortcode creates a [scratch pad] to store and manipulate data. The scratch pad is scoped to the shortcode. + +{{% note %}} +With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Store` method within a shortcode is mostly obsolete. + +[assign values to template variables]: https://go.dev/doc/go1.11#text/template +[`newScratch`]: /functions/collections/newScratch/ +{{% /note %}} + +[Store pad]: /getting-started/glossary/#scratch-pad + +{{% include "methods/page/_common/scratch-methods.md" %}} |