mirror of https://github.com/dmarkham/enumer.git
Add title-lower transform
This commit is contained in:
parent
d806ebd41f
commit
188f5ebedc
|
@ -136,9 +136,10 @@ name := MyTypeValue.String() // name => "my_type_value"
|
||||||
- snake-upper
|
- snake-upper
|
||||||
- kebab
|
- kebab
|
||||||
- kebab-upper
|
- kebab-upper
|
||||||
- lower (Lowercase)
|
- lower (lowercase)
|
||||||
- upper (Uppercase)
|
- upper (UPPERCASE)
|
||||||
- title (TitleCase)
|
- title (TitleCase)
|
||||||
|
- title-lower (titleCase)
|
||||||
- first (Use first character of string)
|
- first (Use first character of string)
|
||||||
- first-lower (same as first only lower case)
|
- first-lower (same as first only lower case)
|
||||||
- first-upper (same as first only upper case)
|
- first-upper (same as first only upper case)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/pascaldekloe/name"
|
"github.com/pascaldekloe/name"
|
||||||
|
@ -272,6 +273,12 @@ func (g *Generator) transformValueNames(values []Value, transformMethod string)
|
||||||
fn = func(s string) string {
|
fn = func(s string) string {
|
||||||
return strings.Title(s)
|
return strings.Title(s)
|
||||||
}
|
}
|
||||||
|
case "title-lower":
|
||||||
|
fn = func(s string) string {
|
||||||
|
title := []rune(strings.Title(s))
|
||||||
|
title[0] = unicode.ToLower(title[0])
|
||||||
|
return string(title)
|
||||||
|
}
|
||||||
case "first":
|
case "first":
|
||||||
fn = func(s string) string {
|
fn = func(s string) string {
|
||||||
r, _ := utf8.DecodeRuneInString(s)
|
r, _ := utf8.DecodeRuneInString(s)
|
||||||
|
|
Loading…
Reference in New Issue