Aurora. Uix. Helpers. Common
(Aurora UIX v0.1.4-rc.7)
Copy Markdown
Provides utility functions for string and atom conversion.
Summary
Functions
Capitalizes a given string by converting underscores to spaces and capitalizing each word.
Safely converts a binary to an atom, creating it if necessary.
Safely converts a binary to an existing atom without raising an exception.
Functions
Capitalizes a given string by converting underscores to spaces and capitalizing each word.
Processes the input by converting it to a string, applying Macro.underscore/1,
replacing consecutive underscores with a single underscore, replacing underscores
with spaces, splitting by spaces, and capitalizing each word.
Empty or nil input returns an empty string.
Parameters
string(binary() | nil) - The string to capitalize.
Returns
binary() - The capitalized string.
Examples
iex> capitalize("hello_world")
"Hello World"
iex> capitalize("HelloWorld")
"Hello World"
iex> capitalize(nil)
""
Safely converts a binary to an atom, creating it if necessary.
If the input is already an atom, returns it unchanged. Any other input returns nil.
Parameters
name(term() | nil) - The name to convert to an atom.
Returns
atom() | nil - The atom if conversion is successful, otherwise nil.
Safely converts a binary to an existing atom without raising an exception.
Returns the atom if it exists in the current runtime, otherwise returns nil. If the input is already an atom, returns it unchanged. Any other input returns nil.
Parameters
name(term() | nil) - The name to convert to an atom.
Returns
atom() | nil - The existing atom if it exists, otherwise nil.