From 4b8f6b99145339472f3a44fa665c616158fb3540 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Fri, 22 Dec 2023 09:59:17 -0800 Subject: [PATCH] Add id attributes to Scratch and Store methods --- .../en/functions/collections/NewScratch.md | 42 +++++++++++-------- content/en/methods/page/Store.md | 37 +++++++++------- .../methods/page/_common/scratch-methods.md | 37 +++++++++------- 3 files changed, 69 insertions(+), 47 deletions(-) diff --git a/content/en/functions/collections/NewScratch.md b/content/en/functions/collections/NewScratch.md index 793b2b4b5..b944bc70d 100644 --- a/content/en/functions/collections/NewScratch.md +++ b/content/en/functions/collections/NewScratch.md @@ -20,16 +20,18 @@ The `collections.NewScratch` function creates a locally scoped [scratch pad] to ## Methods -Set -: Sets the value of a given key. +###### Set + +Sets the value of a given key. ```go-html-template {{ $s := newScratch }} {{ $s.Set "greeting" "Hello" }} ``` -Get -: Gets the value of a given key. +###### Get + +Gets the value of a given key. ```go-html-template {{ $s := newScratch }} @@ -37,10 +39,11 @@ Get {{ $s.Get "greeting" }} → Hello ``` -Add -: Adds a given value to existing value(s) of the given key. +###### Add -: For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. +Adds a given value to existing value(s) of the given key. + +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. ```go-html-template {{ $s := newScratch }} @@ -63,8 +66,9 @@ Add {{ $s.Get "greetings" }} → [Hello Welcome Cheers] ``` -SetInMap -: Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. +###### SetInMap + +Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. ```go-html-template {{ $s := newScratch }} @@ -73,8 +77,9 @@ SetInMap {{ $s.Get "greetings" }} → map[english:Hello french:Bonjour] ``` -DeleteInMap -: Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. +###### DeleteInMap + +Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. ```go-html-template {{ $s := newScratch }} @@ -84,8 +89,9 @@ DeleteInMap {{ $s.Get "greetings" }} → map[french:Bonjour] ``` -GetSortedMapValues -: Returns an array of values from `key` sorted by `mapKey`. +###### GetSortedMapValues + +Returns an array of values from `key` sorted by `mapKey`. ```go-html-template {{ $s := newScratch }} @@ -94,8 +100,9 @@ GetSortedMapValues {{ $s.GetSortedMapValues "greetings" }} → [Hello Bonjour] ``` -Delete -: Removes the given key. +###### Delete + +Removes the given key. ```go-html-template {{ $s := newScratch }} @@ -103,8 +110,9 @@ Delete {{ $s.Delete "greeting" }} ``` -Values -: Returns the raw backing map. Do not use with `Scratch` or `Store` methods on a `Page` object due to concurrency issues. +###### Values + +Returns the raw backing map. Do not use with `Scratch` or `Store` methods on a `Page` object due to concurrency issues. ```go-html-template {{ $s := newScratch }} diff --git a/content/en/methods/page/Store.md b/content/en/methods/page/Store.md index 04e1d5256..8bc16034b 100644 --- a/content/en/methods/page/Store.md +++ b/content/en/methods/page/Store.md @@ -22,25 +22,28 @@ To create a locally scoped scratch pad that is not attached to a `Page` object, ## Methods -Set -: Sets the value of a given key. +###### Set + +Sets the value of a given key. ```go-html-template {{ .Store.Set "greeting" "Hello" }} ``` -Get -: Gets the value of a given key. +###### Get + +Gets the value of a given key. ```go-html-template {{ .Store.Set "greeting" "Hello" }} {{ .Store.Get "greeting" }} → Hello ``` -Add -: Adds a given value to existing value(s) of the given key. +###### Add -: For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. +Adds a given value to existing value(s) of the given key. + +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. ```go-html-template {{ .Store.Set "greeting" "Hello" }} @@ -60,8 +63,9 @@ Add {{ .Store.Get "greetings" }} → [Hello Welcome Cheers] ``` -SetInMap -: Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. +###### SetInMap + +Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. ```go-html-template {{ .Store.SetInMap "greetings" "english" "Hello" }} @@ -69,8 +73,9 @@ SetInMap {{ .Store.Get "greetings" }} → map[english:Hello french:Bonjour] ``` -DeleteInMap -: Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. +###### DeleteInMap + +Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. ```go-html-template {{ .Store.SetInMap "greetings" "english" "Hello" }} @@ -79,8 +84,9 @@ DeleteInMap {{ .Store.Get "greetings" }} → map[french:Bonjour] ``` -GetSortedMapValues -: Returns an array of values from `key` sorted by `mapKey`. +###### GetSortedMapValues + +Returns an array of values from `key` sorted by `mapKey`. ```go-html-template {{ .Store.SetInMap "greetings" "english" "Hello" }} @@ -88,8 +94,9 @@ GetSortedMapValues {{ .Store.GetSortedMapValues "greetings" }} → [Hello Bonjour] ``` -Delete -: Removes the given key. +###### Delete + +Removes the given key. ```go-html-template {{ .Store.Set "greeting" "Hello" }} diff --git a/content/en/methods/page/_common/scratch-methods.md b/content/en/methods/page/_common/scratch-methods.md index c09b4aadc..b2650cdde 100644 --- a/content/en/methods/page/_common/scratch-methods.md +++ b/content/en/methods/page/_common/scratch-methods.md @@ -4,25 +4,28 @@ ## Methods -Set -: Sets the value of a given key. +###### Set + +Sets the value of a given key. ```go-html-template {{ .Scratch.Set "greeting" "Hello" }} ``` -Get -: Gets the value of a given key. +###### Get + +Gets the value of a given key. ```go-html-template {{ .Scratch.Set "greeting" "Hello" }} {{ .Scratch.Get "greeting" }} → Hello ``` -Add -: Adds a given value to existing value(s) of the given key. +###### Add -: For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. +Adds a given value to existing value(s) of the given key. + +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. ```go-html-template {{ .Scratch.Set "greeting" "Hello" }} @@ -42,8 +45,9 @@ Add {{ .Scratch.Get "greetings" }} → [Hello Welcome Cheers] ``` -SetInMap -: Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. +###### SetInMap + +Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`. ```go-html-template {{ .Scratch.SetInMap "greetings" "english" "Hello" }} @@ -51,8 +55,9 @@ SetInMap {{ .Scratch.Get "greetings" }} → map[english:Hello french:Bonjour] ``` -DeleteInMap -: Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. +###### DeleteInMap + +Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`. ```go-html-template {{ .Scratch.SetInMap "greetings" "english" "Hello" }} @@ -61,8 +66,9 @@ DeleteInMap {{ .Scratch.Get "greetings" }} → map[french:Bonjour] ``` -GetSortedMapValues -: Returns an array of values from `key` sorted by `mapKey`. +###### GetSortedMapValues + +Returns an array of values from `key` sorted by `mapKey`. ```go-html-template {{ .Scratch.SetInMap "greetings" "english" "Hello" }} @@ -70,8 +76,9 @@ GetSortedMapValues {{ .Scratch.GetSortedMapValues "greetings" }} → [Hello Bonjour] ``` -Delete -: Removes the given key. +###### Delete + +Removes the given key. ```go-html-template {{ .Scratch.Set "greeting" "Hello" }}