summaryrefslogtreecommitdiffstats
path: root/tpl/inflect
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-12-21 13:11:08 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-12-21 15:33:02 +0100
commitcd1ed563a82f8a9ebdd3109230e34e74bf5ec6eb (patch)
treed766a7d88e59d20be9380aaf3d45b799737a288e /tpl/inflect
parentaa2c724195ae53e698dfaa7f9bea63e5cecea391 (diff)
tpl: Improve template funcs GoDoc
Diffstat (limited to 'tpl/inflect')
-rw-r--r--tpl/inflect/inflect.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/tpl/inflect/inflect.go b/tpl/inflect/inflect.go
index 1f887cecd..ef12e1bc0 100644
--- a/tpl/inflect/inflect.go
+++ b/tpl/inflect/inflect.go
@@ -30,16 +30,12 @@ func New() *Namespace {
// Namespace provides template functions for the "inflect" namespace.
type Namespace struct{}
-// Humanize returns the humanized form of a single parameter.
+// Humanize returns the humanized form of v.
//
-// If the parameter is either an integer or a string containing an integer
+// If v is either an integer or a string containing an integer
// value, the behavior is to add the appropriate ordinal.
-//
-// Example: "my-first-post" -> "My first post"
-// Example: "103" -> "103rd"
-// Example: 52 -> "52nd"
-func (ns *Namespace) Humanize(in any) (string, error) {
- word, err := cast.ToStringE(in)
+func (ns *Namespace) Humanize(v any) (string, error) {
+ word, err := cast.ToStringE(v)
if err != nil {
return "", err
}
@@ -48,7 +44,7 @@ func (ns *Namespace) Humanize(in any) (string, error) {
return "", nil
}
- _, ok := in.(int) // original param was literal int value
+ _, ok := v.(int) // original param was literal int value
_, err = strconv.Atoi(word) // original param was string containing an int value
if ok || err == nil {
return _inflect.Ordinalize(word), nil
@@ -58,9 +54,9 @@ func (ns *Namespace) Humanize(in any) (string, error) {
return _inflect.Humanize(strings.ToLower(str)), nil
}
-// Pluralize returns the plural form of a single word.
-func (ns *Namespace) Pluralize(in any) (string, error) {
- word, err := cast.ToStringE(in)
+// Pluralize returns the plural form of the single word in v.
+func (ns *Namespace) Pluralize(v any) (string, error) {
+ word, err := cast.ToStringE(v)
if err != nil {
return "", err
}
@@ -68,9 +64,9 @@ func (ns *Namespace) Pluralize(in any) (string, error) {
return _inflect.Pluralize(word), nil
}
-// Singularize returns the singular form of a single word.
-func (ns *Namespace) Singularize(in any) (string, error) {
- word, err := cast.ToStringE(in)
+// Singularize returns the singular form of a single word in v.
+func (ns *Namespace) Singularize(v any) (string, error) {
+ word, err := cast.ToStringE(v)
if err != nil {
return "", err
}