Recase
helps you to convert a string from any case to any case.
One can ask: "Why should I use Recase
when I can use built-in Macro
module?". But, you have to keep in mind that Macro
's functions are not suitable for general case usage:
Do not use it as a general mechanism for underscoring or camelizing strings as it does not support Unicode or characters that are not valid in Elixir identifiers.
def deps do
[
{:recase, "~> 0.5"}
]
end
Pascal (or Upper) case uses mixed case with lower and upper cased characters. Separates words from each other with the upper case letters. Starts with upper case letter.
Recase.to_pascal("some-value") # => "SomeValue"
Recase.to_pascal("Some value") # => "SomeValue"
Camel case uses mixed case with lower and upper cased characters. Separates words from each other with the upper cased letters. Starts with lower case letter.
Recase.to_camel("some-value") # => "someValue"
Recase.to_camel("Some Value") # => "someValue"
Snake cases uses all lower case. Uses _
as a separator.
Recase.to_snake("someValue") # => "some_value"
Recase.to_snake("Some Value") # => "some_value"
Kebab cases uses all lower case. Uses -
as a separator.
Recase.to_kebab("someValue") # => "some-value"
Recase.to_kebab("Some Value") # => "some-value"