ex_twiml v2.0.1 ExTwiml.Utilities

A grab bag of helpful functions used to generate XML.

Summary

Functions

Convert a string to headless camelCase

Capitalize a string or atom

Generate a list of HTML attributes from a keyword list. Keys will be converted to headless camelCase

Functions

camelize(string)

Specs

camelize(String.t) :: String.t

Convert a string to headless camelCase.

Examples

...> ExTwiml.Utilities.camelize("finish_on_key")
"finishOnKey"
capitalize(atom)

Specs

capitalize(atom) :: String.t

Capitalize a string or atom.

Examples

iex> ExTwiml.Utilities.capitalize(:atom)
"Atom"

iex> ExTwiml.Utilities.capitalize("string")
"String"
create_tag(type, name, options \\ [])

Specs

create_tag(atom, atom, Keyword.t) :: String.t

Generates an XML tag.

Examples

iex> ExTwiml.Utilities.create_tag(:opening, :say, [voice: "woman"])
"<Say voice=\"woman\">"

iex> ExTwiml.Utilities.create_tag(:self_closed, :pause, [length: 5])
"<Pause length=\"5\" />"

iex> ExTwiml.Utilities.create_tag(:closing, :say)
"</Say>"
xml_attributes(attrs)

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 camelize/1 function for more details.

Examples

iex> ExTwiml.Utilities.xml_attributes([digits: 1, finish_on_key: "#"])
" digits=\"1\" finishOnKey=\"#\""