View Source Transmogrify.Camelcase (transmogrify v2.0.1)

Convert strings to CamelCase

Summary

Functions

Convert a string to camelCase, usually when originally snake_case, using the following rules

Functions

@spec convert(String.t() | atom()) :: String.t()

Convert a string to camelCase, usually when originally snake_case, using the following rules:

  • ascii alphabetic letters immediately following an underscore are capitalized
  • underscores are removed
  • existing case and other characters are preserved in all other cases

TODO: xref common feels around camelcase — spaces? other chars?

iex> convert("_camel___case__")
"camelCase"
iex> convert("camel_case")
"camelCase"
iex> convert("camel_9case")
"camel9case"
iex> convert("camel_case")
"camelCase"
iex> convert("CamelCASE")
"CamelCASE"
iex> convert("Camel_CASE")
"CamelCASE"
iex> convert("CamelCase")
"CamelCase"
iex> convert(:CamelCase)
"CamelCase"