Case
provide.foundation.formatting.case
¶
TODO: Add module docstring.
Functions¶
to_camel_case
¶
Convert text to camelCase or PascalCase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to convert |
required |
upper_first
|
bool
|
Use PascalCase instead of camelCase |
False
|
Returns:
| Type | Description |
|---|---|
str
|
camelCase or PascalCase text |
Examples:
>>> to_camel_case("hello_world")
'helloWorld'
>>> to_camel_case("hello-world", upper_first=True)
'HelloWorld'
Source code in provide/foundation/formatting/case.py
to_kebab_case
¶
Convert text to kebab-case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to convert |
required |
Returns:
| Type | Description |
|---|---|
str
|
kebab-case text |
Examples:
>>> to_kebab_case("HelloWorld")
'hello-world'
>>> to_kebab_case("some_snake_case")
'some-snake-case'
Source code in provide/foundation/formatting/case.py
to_snake_case
¶
Convert text to snake_case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to convert |
required |
Returns:
| Type | Description |
|---|---|
str
|
snake_case text |
Examples:
>>> to_snake_case("HelloWorld")
'hello_world'
>>> to_snake_case("some-kebab-case")
'some_kebab_case'