summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-08-19 13:16:00 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-09-06 00:20:02 +0200
commit3b4f17bbc9ff789faa581ac278ad109d1ac5b816 (patch)
tree7b706ad5fce15afa1825b6565bae09bc517cc687 /tpl
parent16c9127663951ace1a3901cf669c49cc72780ced (diff)
hugolib: Implement "related content"
This closes #98, even if this commit does not do full content text search. We may revisit that problem in the future, but that deserves its own issue. Fixes #98
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/collections.go6
-rw-r--r--tpl/collections/init.go7
2 files changed, 13 insertions, 0 deletions
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
index bc80acbbe..8f09097a7 100644
--- a/tpl/collections/collections.go
+++ b/tpl/collections/collections.go
@@ -23,6 +23,7 @@ import (
"strings"
"time"
+ "github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cast"
@@ -641,3 +642,8 @@ func (ns *Namespace) Uniq(l interface{}) (interface{}, error) {
}
return ret.Interface(), nil
}
+
+// KeyVals creates a key and values wrapper.
+func (ns *Namespace) KeyVals(key interface{}, vals ...interface{}) (types.KeyValues, error) {
+ return types.KeyValues{Key: key, Values: vals}, nil
+}
diff --git a/tpl/collections/init.go b/tpl/collections/init.go
index 4a7c2d875..91b0dea01 100644
--- a/tpl/collections/init.go
+++ b/tpl/collections/init.go
@@ -63,6 +63,13 @@ func init() {
[][2]string{},
)
+ ns.AddMethodMapping(ctx.KeyVals,
+ []string{"keyVals"},
+ [][2]string{
+ {`{{ keyVals "key" "a" "b" }}`, `key: [a b]`},
+ },
+ )
+
ns.AddMethodMapping(ctx.In,
[]string{"in"},
[][2]string{