tpl/transform: Add transform.Unmarshal func

Fixes #5428
This commit is contained in:
Bjørn Erik Pedersen
2018-12-21 16:21:13 +01:00
parent 43f9df0194
commit 822dc627a1
20 changed files with 633 additions and 74 deletions

View File

@@ -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.