mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-01 16:10:07 +03:00
Merge commit 'e477373487
'
This commit is contained in:
commit
b47376586a
73 changed files with 705 additions and 163 deletions
|
@ -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 >}}
|
||||
|
|
|
@ -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.
|
||||
|
|
29
docs/content/en/methods/shortcode/Store.md
Normal file
29
docs/content/en/methods/shortcode/Store.md
Normal 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" %}}
|
Loading…
Add table
Add a link
Reference in a new issue