summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-04-30 19:11:18 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-05-01 15:13:41 +0200
commit656155736721547fef45466a28295f6a563cdd1f (patch)
tree13aa671f78461950a8370779f0cda1ced8b4d4f8 /tpl
parent0ab23eb5a87efd7db96e11fb3665f0d30336217c (diff)
tpl/data: Make it a package that stands on its own
See #3042
Diffstat (limited to 'tpl')
-rw-r--r--tpl/data/init.go43
-rw-r--r--tpl/tplimpl/templateFuncster.go3
-rw-r--r--tpl/tplimpl/template_funcs.go3
3 files changed, 44 insertions, 5 deletions
diff --git a/tpl/data/init.go b/tpl/data/init.go
new file mode 100644
index 000000000..476e9ab75
--- /dev/null
+++ b/tpl/data/init.go
@@ -0,0 +1,43 @@
+// Copyright 2017 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package data
+
+import (
+ "github.com/spf13/hugo/deps"
+ "github.com/spf13/hugo/tpl/internal"
+)
+
+const name = "data"
+
+func init() {
+ f := func(d *deps.Deps) *internal.TemplateFuncsNamespace {
+ ctx := New(d)
+
+ examples := [][2]string{
+ {},
+ }
+
+ return &internal.TemplateFuncsNamespace{
+ Name: name,
+ Context: func() interface{} { return ctx },
+ Aliases: map[string]interface{}{
+ "getCSV": ctx.GetCSV,
+ "getJSON": ctx.GetJSON,
+ },
+ Examples: examples,
+ }
+ }
+
+ internal.AddTemplateFuncsNamespace(f)
+}
diff --git a/tpl/tplimpl/templateFuncster.go b/tpl/tplimpl/templateFuncster.go
index 770eaf46e..a3ad97a29 100644
--- a/tpl/tplimpl/templateFuncster.go
+++ b/tpl/tplimpl/templateFuncster.go
@@ -23,7 +23,6 @@ import (
"github.com/spf13/hugo/deps"
"github.com/spf13/hugo/tpl/collections"
"github.com/spf13/hugo/tpl/crypto"
- "github.com/spf13/hugo/tpl/data"
"github.com/spf13/hugo/tpl/encoding"
"github.com/spf13/hugo/tpl/images"
"github.com/spf13/hugo/tpl/inflect"
@@ -42,7 +41,6 @@ type templateFuncster struct {
// Namespaces
collections *collections.Namespace
crypto *crypto.Namespace
- data *data.Namespace
encoding *encoding.Namespace
images *images.Namespace
inflect *inflect.Namespace
@@ -63,7 +61,6 @@ func newTemplateFuncster(deps *deps.Deps) *templateFuncster {
// Namespaces
collections: collections.New(deps),
crypto: crypto.New(),
- data: data.New(deps),
encoding: encoding.New(),
images: images.New(deps),
inflect: inflect.New(),
diff --git a/tpl/tplimpl/template_funcs.go b/tpl/tplimpl/template_funcs.go
index acf7790f0..3e4fc558a 100644
--- a/tpl/tplimpl/template_funcs.go
+++ b/tpl/tplimpl/template_funcs.go
@@ -25,6 +25,7 @@ import (
"github.com/spf13/hugo/tpl/internal"
// Init the namespaces
+ _ "github.com/spf13/hugo/tpl/data"
_ "github.com/spf13/hugo/tpl/lang"
_ "github.com/spf13/hugo/tpl/math"
_ "github.com/spf13/hugo/tpl/strings"
@@ -107,8 +108,6 @@ func (t *templateFuncster) initFuncMap() {
"eq": compare.Eq,
"first": t.collections.First,
"ge": compare.Ge,
- "getCSV": t.data.GetCSV,
- "getJSON": t.data.GetJSON,
"getenv": t.os.Getenv,
"gt": compare.Gt,
"highlight": t.transform.Highlight,