Add support for titlecase transformation to strings processor (#6982)
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
type Strings struct {
|
||||
Lowercase []converter `toml:"lowercase"`
|
||||
Uppercase []converter `toml:"uppercase"`
|
||||
Titlecase []converter `toml:"titlecase"`
|
||||
Trim []converter `toml:"trim"`
|
||||
TrimLeft []converter `toml:"trim_left"`
|
||||
TrimRight []converter `toml:"trim_right"`
|
||||
@@ -55,6 +56,10 @@ const sampleConfig = `
|
||||
# field = "uri_stem"
|
||||
# dest = "uri_stem_normalised"
|
||||
|
||||
## Convert a field value to titlecase
|
||||
# [[processors.strings.titlecase]]
|
||||
# field = "status"
|
||||
|
||||
## Trim leading and trailing whitespace using the default cutset
|
||||
# [[processors.strings.trim]]
|
||||
# field = "message"
|
||||
@@ -235,6 +240,10 @@ func (s *Strings) initOnce() {
|
||||
c.fn = strings.ToUpper
|
||||
s.converters = append(s.converters, c)
|
||||
}
|
||||
for _, c := range s.Titlecase {
|
||||
c.fn = strings.Title
|
||||
s.converters = append(s.converters, c)
|
||||
}
|
||||
for _, c := range s.Trim {
|
||||
c := c
|
||||
if c.Cutset != "" {
|
||||
|
||||
Reference in New Issue
Block a user