ExTwiml.Utilities
A grab bag of helpful functions used to generate XML.
opening_tag/3
: Generate an XML open tag.closing_tag/1
: Generate an XML close tag.generate_xml_attributes/1
: Generate a list of XML attributes.capitalize/1
: Capitalize a string or atom.to_camel_case/1
: Convert a string or atom to headless camelCase.
Summary↑
capitalize(atom) | Capitalize a string or atom |
closing_tag(tag_name) | Generates a closing XML tag |
opening_tag(tag_name, close, options \\ []) | Generates an opening XML tag |
to_camel_case(string) | Convert a string to headless camelCase |
xml_attributes(attrs) | Generate a list of HTML attributes from a keyword list. Keys will be converted to headless camelCase |
Functions
Specs:
- capitalize(atom) :: String.t
Capitalize a string or atom.
Examples
iex> import ExTwiml.Utilities
...> capitalize(:atom)
"Atom"
...> capitalize("string")
"String"
Specs:
- closing_tag(atom) :: String.t
Generates a closing XML tag.
Examples
iex> import ExTwiml.Utilities
...> closing_tag("say")
"</Say>"
Specs:
Generates an opening XML tag.
Examples
iex> import ExTwiml.Utilities
...> opening_tag "say", "", option_1: "value"
"<Say option1=\"value\">"
...> opening_tag "say", " /", option_1: "value"
"<Say option1=\"value\" />"
Specs:
Convert a string to headless camelCase.
Examples
iex> import ExTwiml.Utilities
...> to_camel_case("finish_on_key")
"finishOnKey"
Specs:
- xml_attributes(list) :: String.t
Generate a list of HTML attributes from a keyword list. Keys will be converted to headless camelCase.
See the to_camel_case/1
function for more details.
Examples
iex> import ExTwiml.Utilities
...> xml_attributes([digits: 1, finish_on_key: "#"])
" digits=\"1\" finishOnKey=\"#\""