summaryrefslogtreecommitdiffstats
path: root/tpl/transform/transform.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/transform/transform.go')
-rw-r--r--tpl/transform/transform.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/tpl/transform/transform.go b/tpl/transform/transform.go
index 777e31c3e..42e36eb0f 100644
--- a/tpl/transform/transform.go
+++ b/tpl/transform/transform.go
@@ -19,6 +19,8 @@ import (
"html"
"html/template"
+ "github.com/gohugoio/hugo/cache/namedmemcache"
+
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cast"
@@ -26,14 +28,22 @@ import (
// New returns a new instance of the transform-namespaced template functions.
func New(deps *deps.Deps) *Namespace {
+ cache := namedmemcache.New()
+ deps.BuildStartListeners.Add(
+ func() {
+ cache.Clear()
+ })
+
return &Namespace{
- deps: deps,
+ cache: cache,
+ deps: deps,
}
}
// Namespace provides template functions for the "transform" namespace.
type Namespace struct {
- deps *deps.Deps
+ cache *namedmemcache.Cache
+ deps *deps.Deps
}
// Emojify returns a copy of s with all emoji codes replaced with actual emojis.