aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl
diff options
context:
space:
mode:
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/collections.go49
-rw-r--r--tpl/collections/collections_test.go33
-rw-r--r--tpl/collections/init.go5
-rw-r--r--tpl/lang/lang.go7
4 files changed, 0 insertions, 94 deletions
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
index edec536ef..a7e36f689 100644
--- a/tpl/collections/collections.go
+++ b/tpl/collections/collections.go
@@ -26,7 +26,6 @@ import (
"time"
"github.com/gohugoio/hugo/common/collections"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
@@ -189,54 +188,6 @@ func (ns *Namespace) Dictionary(values ...any) (map[string]any, error) {
return root, nil
}
-// EchoParam returns the value in the collection c with key k if is set; otherwise, it returns an
-// empty string.
-// Deprecated: Use the index function instead.
-func (ns *Namespace) EchoParam(c, k any) any {
- hugo.Deprecate("collections.EchoParam", "Use the index function instead.", "v0.120.0")
- av, isNil := indirect(reflect.ValueOf(c))
- if isNil {
- return ""
- }
-
- var avv reflect.Value
- switch av.Kind() {
- case reflect.Array, reflect.Slice:
- index, ok := k.(int)
- if ok && av.Len() > index {
- avv = av.Index(index)
- }
- case reflect.Map:
- kv := reflect.ValueOf(k)
- if kv.Type().AssignableTo(av.Type().Key()) {
- avv = av.MapIndex(kv)
- }
- }
-
- avv, isNil = indirect(avv)
-
- if isNil {
- return ""
- }
-
- if avv.IsValid() {
- switch avv.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return avv.Int()
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return avv.Uint()
- case reflect.Float32, reflect.Float64:
- return avv.Float()
- case reflect.String:
- return avv.String()
- case reflect.Bool:
- return avv.Bool()
- }
- }
-
- return ""
-}
-
// First returns the first limit items in list l.
func (ns *Namespace) First(limit any, l any) (any, error) {
if limit == nil || l == nil {
diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go
index c89051a3d..0f4bf82f5 100644
--- a/tpl/collections/collections_test.go
+++ b/tpl/collections/collections_test.go
@@ -232,39 +232,6 @@ func TestReverse(t *testing.T) {
c.Assert(err, qt.Not(qt.IsNil))
}
-func TestEchoParam(t *testing.T) {
- t.Skip("deprecated, will be removed in Hugo 0.133.0")
- t.Parallel()
- c := qt.New(t)
-
- ns := newNs()
-
- for i, test := range []struct {
- a any
- key any
- expect any
- }{
- {[]int{1, 2, 3}, 1, int64(2)},
- {[]uint{1, 2, 3}, 1, uint64(2)},
- {[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)},
- {[]string{"foo", "bar", "baz"}, 1, "bar"},
- {[]TstX{{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"}}, 1, ""},
- {map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)},
- {map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)},
- {map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)},
- {map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"},
- {map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""},
- {map[string]any{"foo": nil}, "foo", ""},
- {(*[]string)(nil), "bar", ""},
- } {
- errMsg := qt.Commentf("[%d] %v", i, test)
-
- result := ns.EchoParam(test.a, test.key)
-
- c.Assert(result, qt.Equals, test.expect, errMsg)
- }
-}
-
func TestFirst(t *testing.T) {
t.Parallel()
c := qt.New(t)
diff --git a/tpl/collections/init.go b/tpl/collections/init.go
index 20711f9e4..f89651326 100644
--- a/tpl/collections/init.go
+++ b/tpl/collections/init.go
@@ -67,11 +67,6 @@ func init() {
[][2]string{},
)
- ns.AddMethodMapping(ctx.EchoParam,
- []string{"echoParam"},
- [][2]string{},
- )
-
ns.AddMethodMapping(ctx.First,
[]string{"first"},
[][2]string{},
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go
index b4ff98684..4cbd661af 100644
--- a/tpl/lang/lang.go
+++ b/tpl/lang/lang.go
@@ -26,7 +26,6 @@ import (
translators "github.com/gohugoio/localescompressed"
"github.com/gohugoio/hugo/common/hreflect"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/deps"
"github.com/spf13/cast"
)
@@ -240,12 +239,6 @@ func (ns *Namespace) FormatNumberCustom(precision, number any, options ...any) (
return string(b), nil
}
-// Deprecated: Use lang.FormatNumberCustom instead.
-func (ns *Namespace) NumFmt(precision, number any, options ...any) (string, error) {
- hugo.Deprecate("lang.NumFmt", "Use lang.FormatNumberCustom instead.", "v0.120.0")
- return ns.FormatNumberCustom(precision, number, options...)
-}
-
type pagesLanguageMerger interface {
MergeByLanguageInterface(other any) (any, error)
}