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
Add a an or a in front of a word.
Examples
iex> articlize("hat")
"a hat"
iex> articlize("apple")
"an apple"
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"
Generate html for a link
Syntax
iex> link_to("click me", "/something", class: "link btn", style: "some styling")
{:safe, "<a href='/something' class='link btn' style='some styling'>click me</a>"}
Return the plural of a term based on a passed count.
If count is equal to 1, return the singular. Otherwise, return the plural.