Skip to content

bettyblocks/case_style_ex

Repository files navigation

CaseStyle

Convert from and to different CaseStyles.

This library is different than the others, because you need to explicitly say from and to which case you want to convert. This is nice because you can keep some context and this makes it possible to convert between cases without losing data (check the tests for the edge cases).

Usage

Manual method

input = "testing_testing"
# we convert from SnakeCase
{:ok, casing} = CaseStyle.from_string(input, CaseStyle.SnakeCase)
# casing is a struct with a list of tokens
converted = CaseStyle.to_string(casing, CaseStyle.CamelCase)
# converted is "testingTesting"

In the above example the modules can be dynamically passed. If you know what you want upfront you can use the convenience functions:

Convenient method

{:ok, "testingTesting"} = CaseStyle.snake_to_camel("testing_testing")

Installation

If available in Hex, the package can be installed by adding case_style to your list of dependencies in mix.exs:

def deps do
  [
    {:case_style, "~> 0.2.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/case_style.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages