This commit is contained in:
Bjørn Erik Pedersen 2024-12-11 09:53:33 +01:00
commit b47376586a
No known key found for this signature in database
73 changed files with 705 additions and 163 deletions

View file

@ -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 >}}

View file

@ -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.

View file

@ -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" %}}