Store.md - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
Store.md (1476B)
---
1 ---
2 title: Store
3 description: Returns a "scratch pad" to store and manipulate data, scoped to the current page.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: maps.Scratch
9 signatures: [PAGE.Store]
10 aliases: [/functions/store/,/extras/scratch/,/doc/scratch/,/functions/scratch]
11 ---
12
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.
14
15 {{% include "_common/store-methods.md" %}}
16
17 {{% include "_common/scratch-pad-scope.md" %}}
18
19 ## Determinate values
20
21 The `Store` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
22
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:
24
25 ```go-html-template
26 {{ $noop := .Content }}
27 {{ .Store.Get "mykey" }}
28 ```
29
30 You can also trigger content rendering with the `ContentWithoutSummary`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
31
32 ```go-html-template
33 {{ $noop := .WordCount }}
34 {{ .Store.Get "mykey" }}
35 ```