ExAdmin v0.7.4 ExAdmin.Utils

A collection of utility functions.

Summary

Functions

Add a an or a in front of a word

Convert a field name to its human readable form

Generate html for a link

Returns a list of items from list1 that are not in list2

Return the plural of a term

Return the plural of a term based on a passed count

Converts camel case items to human readable form

Functions

articlize(string)

Add a an or a in front of a word.

Examples

iex> articlize("hat")
"a hat"

iex> articlize("apple")
"an apple"
displayable_name_singular(conn)
extract_controller_name(name)
humanize(item, from \\ ~r"[_ ]", to \\ " ")

Convert a field name to its human readable form.

Converts items like field names to a form suitable for display labels and menu items. By default, converts _ to space and capitalizes each word.

The conversion can be customized by passing a from regex and to regex as the 2nd and 3rd arguments.

Examples:

iex> humanize :first_name
"First Name"

iex> humanize "last-name", ~r/[-]/
"Last Name"
not_in(list1, list2)

Returns a list of items from list1 that are not in list2

parameterize(atom)
pluralize(atom)

Return the plural of a term.

Returns a string give an atom or a string.

pluralize(atom, count)

Return the plural of a term based on a passed count.

If count is equal to 1, return the singular. Otherwise, return the plural.

titleize(atom)

Converts camel case items to human readable form.

Examples

iex> titleize "MyModel"
"My Model"