add ToCamelCase function in SUI core
This commit is contained in:
parent
e802599795
commit
2f828b643d
2 changed files with 20 additions and 0 deletions
|
|
@ -357,6 +357,7 @@ func (page *Page) replaceProps(sel *goquery.Selection) error {
|
||||||
}
|
}
|
||||||
data := Data{}
|
data := Data{}
|
||||||
for key, prop := range page.props {
|
for key, prop := range page.props {
|
||||||
|
key = ToCamelCase(key)
|
||||||
data[key] = prop.Val
|
data[key] = prop.Val
|
||||||
}
|
}
|
||||||
data["$props"] = data
|
data["$props"] = data
|
||||||
|
|
|
||||||
|
|
@ -91,3 +91,22 @@ func TranslationKeyPrefix(name string) string {
|
||||||
name = strings.ReplaceAll(name, "]", "_")
|
name = strings.ReplaceAll(name, "]", "_")
|
||||||
return fmt.Sprintf("trans_%s", name)
|
return fmt.Sprintf("trans_%s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToCamelCase convert the string to camel case
|
||||||
|
func ToCamelCase(s string, split ...string) string {
|
||||||
|
splitter := "-"
|
||||||
|
if len(split) > 0 {
|
||||||
|
splitter = split[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
s = strings.ToLower(s)
|
||||||
|
parts := strings.Split(s, splitter)
|
||||||
|
for i, part := range parts {
|
||||||
|
if i == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
parts[i] = strings.ToUpper(part[:1]) + part[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(parts, "")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue