Skip to content

Commit 8875ef7

Browse files
authored
content: Replace "scratch pad" with clearer data structure terminology
1 parent 6e186e5 commit 8875ef7

13 files changed

Lines changed: 52 additions & 36 deletions

File tree

content/en/_common/scratch-pad-scope.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _comment: Do not remove front matter.
44

55
## Scope
66

7-
The method or function used to create a scratch pad determines its scope. For example, use the `Store` method on a `Page` object to create a scratch pad scoped to the page.
7+
The method or function used to create the data structure determines its scope. For example, use the `Store` method on a `Page` object to create a data structure scoped to the page.
88

99
Scope|Method or function
1010
:--|:--

content/en/_common/store-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Methods
66

7-
Use these methods on the scratch pad.
7+
Use these methods on the data structure.
88

99
`Set`
1010
: Sets the value of the given key.

content/en/_common/store-scope.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
_comment: Do not remove front matter.
3+
---
4+
5+
## Scope
6+
7+
The method or function used to create the data structure determines its scope. For example, use the `Store` method on a `Page` object to create a data structure scoped to the page.
8+
9+
Scope|Method or function
10+
:--|:--
11+
page|[`PAGE.Store`]
12+
site|[`SITE.Store`]
13+
global|[`hugo.Store`]
14+
local|[`collections.NewScratch`]
15+
shortcode|[`SHORTCODE.Store`]
16+
17+
[`page.store`]: /methods/page/store
18+
[`site.store`]: /methods/site/store
19+
[`hugo.store`]: /functions/hugo/store
20+
[`collections.newscratch`]: functions/collections/newscratch
21+
[`shortcode.store`]: /methods/shortcode/store

content/en/content-management/content-adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Use these methods within a content adapter.
8585
> Methods that depend on built pages, such as `Site.Pages`, are unavailable at this stage and return an error.
8686
8787
`Store`
88-
: (`maps.Scratch`) Returns a persistent "scratch pad" to store and manipulate data. The main use case for this is to transfer values between executions when [EnableAllLanguages](#enablealllanguages) is set. See [examples](/methods/page/store/).
88+
: (`maps.Scratch`) Returns a persistent data structure for storing and manipulating keyed values. The main use case for this is to transfer values between executions when [EnableAllLanguages](#enablealllanguages) is set. See [examples](/methods/page/store/).
8989

9090
```go-html-template {file="content/books/_content.gotmpl"}
9191
{{ .Store.Set "key" "value" }}

content/en/functions/collections/NewScratch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: collections.NewScratch
3-
description: Returns a locally scoped "scratch pad" to store and manipulate data.
3+
description: Returns a locally scoped persistent data structure for storing and manipulating keyed values.
44
categories: []
55
keywords: []
66
params:
@@ -10,11 +10,11 @@ params:
1010
signatures: [collections.NewScratch]
1111
---
1212

13-
Use the `collections.NewScratch` function to create a locally scoped [scratch pad](g) to store and manipulate data. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
13+
Use the `collections.NewScratch` function to create a locally scoped persistent data structure for storing and manipulating keyed values. To create a data structure with a different [scope](g), refer to the [scope](#scope) section below.
1414

1515
## Methods
1616

17-
Use these methods on the scratch pad.
17+
Use these methods on the data structure.
1818

1919
`Set`
2020
: Sets the value of the given key.
@@ -110,4 +110,4 @@ Use these methods on the scratch pad.
110110
{{ $map := $s.Values }}
111111
```
112112

113-
{{% include "_common/scratch-pad-scope.md" %}}
113+
{{% include "_common/store-scope.md" %}}

content/en/functions/hugo/Store.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: hugo.Store
3-
description: Returns a globally scoped "scratch pad" to store and manipulate data.
3+
description: Returns a globally scoped persistent data structure for storing and manipulating keyed values.
44
categories: []
55
keywords: []
66
params:
@@ -11,11 +11,11 @@ params:
1111

1212
{{< new-in 0.139.0 />}}
1313

14-
Use the `hugo.Store` function to create a globally scoped [scratch pad](g) to store and manipulate data. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
14+
Use the `hugo.Store` function to create a globally scoped persistent data structure for storing and manipulating keyed values. To create a data structure with a different [scope](g), refer to the [scope](#scope) section below.
1515

1616
## Methods
1717

18-
Use these methods on the scratch pad.
18+
Use these methods on the data structure.
1919

2020
`Set`
2121
: Sets the value of the given key.
@@ -91,13 +91,13 @@ Use these methods on the scratch pad.
9191
{{ hugo.Store.Delete "greeting" }}
9292
```
9393

94-
{{% include "_common/scratch-pad-scope.md" %}}
94+
{{% include "_common/store-scope.md" %}}
9595

9696
## Determinate values
9797

98-
The `Store` method is often used to set scratch pad values within a _shortcode_ template, a _partial_ template called by a _shortcode_ template, or by a _render hook_ template. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
98+
The `Store` method is often used to set values within a _shortcode_ template, a _partial_ template called by a _shortcode_ template, or by a _render hook_ template. In all three cases, the stored values are indeterminate until Hugo renders the page content.
9999

100-
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
100+
If you need to access a stored value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
101101

102102
```go-html-template
103103
{{ $noop := .Content }}

content/en/methods/page/Scratch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Scratch
3-
description: Returns a "scratch pad" to store and manipulate data, scoped to the current page.
3+
description: Returns a persistent data structure for storing and manipulating keyed values, scoped to the current page.
44
categories: []
55
keywords: []
66
params:

content/en/methods/page/Store.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Store
3-
description: Returns a "scratch pad" to store and manipulate data, scoped to the current page.
3+
description: Returns a persistent data structure for storing and manipulating keyed values, scoped to the current page.
44
categories: []
55
keywords: []
66
params:
@@ -10,17 +10,17 @@ params:
1010
aliases: [/functions/store/,/extras/scratch/,/doc/scratch/,/functions/scratch]
1111
---
1212

13-
Use the `Store` method on a `Page` object to create a [scratch pad](g) to store and manipulate data, scoped to the current page. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
13+
Use the `Store` method on a `Page` object to create a persistent data structure for storing and manipulating keyed values, scoped to the current page. To create a data structure with a different [scope](g), refer to the [scope](#scope) section below.
1414

1515
{{% include "_common/store-methods.md" %}}
1616

17-
{{% include "_common/scratch-pad-scope.md" %}}
17+
{{% include "_common/store-scope.md" %}}
1818

1919
## Determinate values
2020

21-
The `Store` method is often used to set scratch pad values within a _shortcode_ template, a _partial_ template called by a _shortcode_ template, or by a _render hook_ template. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
21+
The `Store` method is often used to set values within a _shortcode_ template, a _partial_ template called by a _shortcode_ template, or by a _render hook_ template. In all three cases, the stored values are indeterminate until Hugo renders the page content.
2222

23-
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
23+
If you need to access a stored value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
2424

2525
```go-html-template
2626
{{ $noop := .Content }}

content/en/methods/shortcode/Scratch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Scratch
3-
description: Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
3+
description: Returns a persistent data structure for storing and manipulating keyed values, scoped to the current shortcode.
44
categories: []
55
keywords: []
66
params:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Store
3-
description: Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
3+
description: Returns a persistent data structure for storing and manipulating keyed values, scoped to the current shortcode.
44
categories: []
55
keywords: []
66
params:
@@ -11,14 +11,14 @@ params:
1111

1212
{{< new-in 0.139.0 />}}
1313

14-
Use the `Store` method to create a [scratch pad](g) to store and manipulate data, scoped to the current shortcode. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
14+
Use the `Store` method to create a persistent data structure for storing and manipulating keyed values, scoped to the current shortcode. To create a data structure with a different [scope](g), refer to the [scope](#scope) section below.
1515

1616
> [!note]
1717
> 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.
1818
1919
{{% include "_common/store-methods.md" %}}
2020

21-
{{% include "_common/scratch-pad-scope.md" %}}
21+
{{% include "_common/store-scope.md" %}}
2222

2323
[`newScratch`]: /functions/collections/newScratch/
2424
[assign values to template variables]: https://go.dev/doc/go1.11#texttemplatepkgtexttemplate

0 commit comments

Comments
 (0)