Phoenix.Naming
Summary
| camelize(arg1) | Converts String to camel case |
| resource_name(alias, suffix \\ nil) | Extracts the resource name from an alias |
| underscore(arg1) | Converts String to underscore case |
Functions
Converts String to camel case
Examples
iex> Phoenix.Naming.camelize("my_app")
"MyApp"
In general, camelize can be thought of as the reverse of
underscore, however, in some cases formatting may be lost:
Phoenix.Naming.underscore "SAPExample" #=> "sap_example"
Phoenix.Naming.camelize "sap_example" #=> "SapExample"
Extracts the resource name from an alias
Examples
iex> Phoenix.Naming.resource_name(MyApp.User)
"user"
iex> Phoenix.Naming.resource_name(MyApp.UserView, "View")
"user"
Converts String to underscore case
Examples
iex> Phoenix.Naming.underscore("MyApp")
"my_app"
iex> Phoenix.Naming.underscore("my-app")
"my_app"
In general, underscore can be thought of as the reverse of
camelize, however, in some cases formatting may be lost:
Naming.underscore "SAPExample" #=> "sap_example"
Naming.camelize "sap_example" #=> "SapExample"