mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
@@ -38,7 +38,7 @@ type Namespace struct{}
|
||||
// Example: "my-first-post" -> "My first post"
|
||||
// Example: "103" -> "103rd"
|
||||
// Example: 52 -> "52nd"
|
||||
func (ns *Namespace) Humanize(in interface{}) (string, error) {
|
||||
func (ns *Namespace) Humanize(in any) (string, error) {
|
||||
word, err := cast.ToStringE(in)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -59,7 +59,7 @@ func (ns *Namespace) Humanize(in interface{}) (string, error) {
|
||||
}
|
||||
|
||||
// Pluralize returns the plural form of a single word.
|
||||
func (ns *Namespace) Pluralize(in interface{}) (string, error) {
|
||||
func (ns *Namespace) Pluralize(in any) (string, error) {
|
||||
word, err := cast.ToStringE(in)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -69,7 +69,7 @@ func (ns *Namespace) Pluralize(in interface{}) (string, error) {
|
||||
}
|
||||
|
||||
// Singularize returns the singular form of a single word.
|
||||
func (ns *Namespace) Singularize(in interface{}) (string, error) {
|
||||
func (ns *Namespace) Singularize(in any) (string, error) {
|
||||
word, err := cast.ToStringE(in)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@@ -13,9 +13,9 @@ func TestInflect(t *testing.T) {
|
||||
ns := New()
|
||||
|
||||
for _, test := range []struct {
|
||||
fn func(i interface{}) (string, error)
|
||||
in interface{}
|
||||
expect interface{}
|
||||
fn func(i any) (string, error)
|
||||
in any
|
||||
expect any
|
||||
}{
|
||||
{ns.Humanize, "MyCamel", "My camel"},
|
||||
{ns.Humanize, "óbito", "Óbito"},
|
||||
|
@@ -26,7 +26,7 @@ func init() {
|
||||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
Context: func(args ...any) (any, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Humanize,
|
||||
|
Reference in New Issue
Block a user