mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-09 23:50:41 +02:00
@@ -23,6 +23,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
@@ -650,3 +651,9 @@ func (ns *Namespace) Uniq(l interface{}) (interface{}, error) {
|
||||
func (ns *Namespace) KeyVals(key interface{}, vals ...interface{}) (types.KeyValues, error) {
|
||||
return types.KeyValues{Key: key, Values: vals}, nil
|
||||
}
|
||||
|
||||
// NewScratch creates a new Scratch which can be used to store values in a
|
||||
// thread safe way.
|
||||
func (ns *Namespace) NewScratch() *maps.Scratch {
|
||||
return maps.NewScratch()
|
||||
}
|
||||
|
@@ -144,6 +144,14 @@ func init() {
|
||||
{`{{ seq 3 }}`, `[1 2 3]`},
|
||||
},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.NewScratch,
|
||||
[]string{"newScratch"},
|
||||
[][2]string{
|
||||
{`{{ $scratch := newScratch }}{{ $scratch.Add "b" 2 }}{{ $scratch.Add "b" 2 }}{{ $scratch.Get "b" }}`, `4`},
|
||||
},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.Uniq,
|
||||
[]string{"uniq"},
|
||||
[][2]string{
|
||||
|
Reference in New Issue
Block a user