Cozy_case - Converts data between common naming conventions, such as snake_case <-> camelCase

This package converts data between common naming conventions, which is useful when working with other languages using different naming convention, such as JavaScript. :wink:

Currently, it supports following conversations:

name example
snake case welcome_message
kebab case welcome-message
camel case welcomeMessage
pascal case WelcomeMessage


iex> CozyCase.snake_case("HelloWorld")

iex> CozyCase.snake_case("helloWorld")

Other public functions:

  • kebab_case/1
  • camel_case/1
  • pascal_case/1

Related links

Hope you guys like it.

@c4710n I have tried this library using "welcome message" string and here are the result:

iex> Mix.install([:cozy_case])
# …
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?

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…

Haha, you remembered this library cozy_params.

1 Like

Fiexd :joy:

1 Like