diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-30 22:32:40 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-01 15:13:41 +0200 |
commit | 9aee8ace4e04b6b164b3c13d622021168b072baf (patch) | |
tree | 6a41a9a5ae8f7b1aace39de5186ae388cbf1fbda /tpl/tplimpl | |
parent | 744dccbea4a0dfecea4777a7f0d3bba99c2a9adb (diff) |
tpl/encoding: Make it a package that stands on its own
See #3042
Diffstat (limited to 'tpl/tplimpl')
-rw-r--r-- | tpl/tplimpl/templateFuncster.go | 3 | ||||
-rw-r--r-- | tpl/tplimpl/template_funcs.go | 13 | ||||
-rw-r--r-- | tpl/tplimpl/template_funcs_test.go | 8 |
3 files changed, 5 insertions, 19 deletions
diff --git a/tpl/tplimpl/templateFuncster.go b/tpl/tplimpl/templateFuncster.go index 2f018cf32..79a9f29ad 100644 --- a/tpl/tplimpl/templateFuncster.go +++ b/tpl/tplimpl/templateFuncster.go @@ -21,7 +21,6 @@ import ( bp "github.com/spf13/hugo/bufferpool" "github.com/spf13/hugo/deps" - "github.com/spf13/hugo/tpl/encoding" "github.com/spf13/hugo/tpl/images" "github.com/spf13/hugo/tpl/inflect" "github.com/spf13/hugo/tpl/os" @@ -37,7 +36,6 @@ type templateFuncster struct { cachedPartials partialCache // Namespaces - encoding *encoding.Namespace images *images.Namespace inflect *inflect.Namespace os *os.Namespace @@ -55,7 +53,6 @@ func newTemplateFuncster(deps *deps.Deps) *templateFuncster { cachedPartials: partialCache{p: make(map[string]interface{})}, // Namespaces - encoding: encoding.New(), images: images.New(deps), inflect: inflect.New(), os: os.New(deps), diff --git a/tpl/tplimpl/template_funcs.go b/tpl/tplimpl/template_funcs.go index 5adfff212..0f855787c 100644 --- a/tpl/tplimpl/template_funcs.go +++ b/tpl/tplimpl/template_funcs.go @@ -28,6 +28,7 @@ import ( _ "github.com/spf13/hugo/tpl/compare" _ "github.com/spf13/hugo/tpl/crypto" _ "github.com/spf13/hugo/tpl/data" + _ "github.com/spf13/hugo/tpl/encoding" _ "github.com/spf13/hugo/tpl/lang" _ "github.com/spf13/hugo/tpl/math" _ "github.com/spf13/hugo/tpl/strings" @@ -84,19 +85,16 @@ func (t *templateFuncster) partialCached(name string, context interface{}, varia func (t *templateFuncster) initFuncMap() { funcMap := template.FuncMap{ // Namespaces - "encoding": t.encoding.Namespace, - "images": t.images.Namespace, - "inflect": t.inflect.Namespace, - "os": t.os.Namespace, - "safe": t.safe.Namespace, + "images": t.images.Namespace, + "inflect": t.inflect.Namespace, + "os": t.os.Namespace, + "safe": t.safe.Namespace, //"time": t.time.Namespace, "transform": t.transform.Namespace, "urls": t.urls.Namespace, "absURL": t.urls.AbsURL, "absLangURL": t.urls.AbsLangURL, - "base64Decode": t.encoding.Base64Decode, - "base64Encode": t.encoding.Base64Encode, "dateFormat": t.time.Format, "emojify": t.transform.Emojify, "getenv": t.os.Getenv, @@ -106,7 +104,6 @@ func (t *templateFuncster) initFuncMap() { "humanize": t.inflect.Humanize, "imageConfig": t.images.Config, "int": func(v interface{}) (int, error) { return cast.ToIntE(v) }, - "jsonify": t.encoding.Jsonify, "markdownify": t.transform.Markdownify, "now": t.time.Now, "partial": t.partial, diff --git a/tpl/tplimpl/template_funcs_test.go b/tpl/tplimpl/template_funcs_test.go index 053457557..52bf499ac 100644 --- a/tpl/tplimpl/template_funcs_test.go +++ b/tpl/tplimpl/template_funcs_test.go @@ -124,9 +124,6 @@ func TestFuncsInTemplate(t *testing.T) { absURL: {{ "http://gohugo.io/" | absURL }} absURL: {{ "mystyle.css" | absURL }} absURL: {{ 42 | absURL }} -base64Decode 1: {{ "SGVsbG8gd29ybGQ=" | base64Decode }} -base64Decode 2: {{ 42 | base64Encode | base64Decode }} -base64Encode: {{ "Hello world" | base64Encode }} crypto.MD5: {{ crypto.MD5 "Hello world, gophers!" }} dateFormat: {{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }} emojify: {{ "I :heart: Hugo" | emojify }} @@ -141,7 +138,6 @@ humanize 1: {{ humanize "my-first-post" }} humanize 2: {{ humanize "myCamelPost" }} humanize 3: {{ humanize "52" }} humanize 4: {{ humanize 103 }} -jsonify: {{ (slice "A" "B" "C") | jsonify }} markdownify: {{ .Title | markdownify}} print: {{ print "works!" }} printf: {{ printf "%s!" "works" }} @@ -169,9 +165,6 @@ urlize: {{ "Bat Man" | urlize }} absURL: http://gohugo.io/ absURL: http://mysite.com/hugo/mystyle.css absURL: http://mysite.com/hugo/42 -base64Decode 1: Hello world -base64Decode 2: 42 -base64Encode: SGVsbG8gd29ybGQ= crypto.MD5: b3029f756f98f79e7f1b7f1d1f0dd53b dateFormat: Wednesday, Jan 21, 2015 emojify: I ❤️ Hugo @@ -186,7 +179,6 @@ humanize 1: My first post humanize 2: My camel post humanize 3: 52nd humanize 4: 103rd -jsonify: ["A","B","C"] markdownify: <strong>BatMan</strong> print: works! printf: works! |