c4710n
January 10, 2023, 1:13pm
1
This package converts data between common naming conventions, which is useful when working with other languages using different naming convention, such as JavaScript.
Currently, it supports following conversations:
name
example
snake case
welcome_message
kebab case
welcome-message
camel case
welcomeMessage
pascal case
WelcomeMessage
Examples
iex> CozyCase.snake_case("HelloWorld")
"hello_world"
iex> CozyCase.snake_case("helloWorld")
"hello_world"
Other public functions:
kebab_case/1
camel_case/1
pascal_case/1
Related links
Hope you guys like it.
Eiji
January 10, 2023, 1:56pm
2
@c4710n I have tried this library using "welcome message"
string and here are the result:
iex> Mix.install([:cozy_case])
# …
:ok
iex> CozyCase.camel_case("welcome message")
"welcome message"
iex> CozyCase.kebab_case("welcome message")
"welcome message"
iex> CozyCase.pascal_case("welcome message")
"Welcome message"
iex> CozyCase.snake_case("welcome message")
"welcome message"
Looks like you made it to work only with module
names and simple form input names, right?
c4710n
January 10, 2023, 2:23pm
3
Currently, it only supports the convertion between above 4 cases.
"welcome message"
is not in above 4 cases, so I haven’t considered this situation yet…
c4710n
January 10, 2023, 2:25pm
4
Haha, you remembered this library cozy_params
.
1 Like