package hstore

import "github.com/gohugoio/hugo/common/hstore"

Index

Types

type Scratch

type Scratch struct {
	// contains filtered or unexported fields
}

Scratch is a writable context used for stateful build operations

func NewScratch

func NewScratch() *Scratch

NewScratch returns a new instance of Scratch.

func (*Scratch) Add

func (c *Scratch) Add(key string, newAddend any) (string, error)

Add will, for single values, add (using the + operator) the addend to the existing addend (if found). Supports numeric values and strings.

If the first add for a key is an array or slice, then the next value(s) will be appended.

func (*Scratch) Delete

func (c *Scratch) Delete(key string) string

Delete deletes the given key.

func (*Scratch) DeleteInMap

func (c *Scratch) DeleteInMap(key string, mapKey string) string

DeleteInMap deletes a value to a map with the given key in the Node context.

func (*Scratch) Get

func (c *Scratch) Get(key string) any

Get returns a value previously set by Add or Set.

func (*Scratch) GetSortedMapValues

func (c *Scratch) GetSortedMapValues(key string) any

GetSortedMapValues returns a sorted map previously filled with SetInMap.

func (*Scratch) Set

func (c *Scratch) Set(key string, value any) string

Set stores a value with the given key in the Node context. This value can later be retrieved with Get.

func (*Scratch) SetInMap

func (c *Scratch) SetInMap(key string, mapKey string, value any) string

SetInMap stores a value to a map with the given key in the Node context. This map can later be retrieved with GetSortedMapValues.

func (*Scratch) Values

func (c *Scratch) Values() map[string]any

Values returns the raw backing map. Note that you should just use this method on the locally scoped Scratch instances you obtain via newScratch, not .Page.Scratch etc., as that will lead to concurrency issues.

type StoreProvider

type StoreProvider interface {
	// Store returns a Scratch that can be used to store temporary state.
	// Store is not reset on server rebuilds.
	Store() *Scratch
}

Source Files

scratch.go

Version
v0.153.4 (latest)
Published
Dec 28, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
4 months ago

Tools for package owners.