Brady (brady v0.0.9)
Link to this section Summary
Functions
Returns the controller name and controller-action name as a lowercase, dasherized string.
Encodes an image to base64-encoded data uri, compatible for img src attributes. Only recommended for files less than 2kb. This threshold is configurable with mix config
Embeds an html safe raw SVG in the markup. Also takes an optional list of CSS attributes and applies those to the SVG.
Link to this section Functions
body_class(conn)
Specs
body_class(%Plug.Conn{ adapter: term(), assigns: term(), before_send: term(), body_params: term(), cookies: term(), halted: term(), host: term(), method: term(), owner: term(), params: term(), path_info: term(), peer: term(), port: term(), private: term(), query_params: term(), query_string: term(), remote_ip: term(), req_cookies: term(), req_headers: term(), request_path: term(), resp_body: term(), resp_cookies: term(), resp_headers: term(), scheme: term(), script_name: term(), secret_key_base: term(), state: term(), status: term() }) :: String.t()
Returns the controller name and controller-action name as a lowercase, dasherized string.
For example, when the conn
came from CoolWidgetsController#show:
Brady.body_class(conn) => 'cool-widgets cool-widgets-show'"
data_uri(path)
Encodes an image to base64-encoded data uri, compatible for img src attributes. Only recommended for files less than 2kb. This threshold is configurable with mix config:
config :brady, inline_threshold: 10_240
Ex:
Brady.data_uri("placeholder.gif")
# => "data:image/gif;base64,iVBORw0KGgoAAAA"
inline_svg(file_name, options \\ [])
Specs
Embeds an html safe raw SVG in the markup. Also takes an optional list of CSS attributes and applies those to the SVG.
Ex:
Brady.inline_svg("test", class: "foo", "data-role": "bar") =>
{:safe,
"<svg class="foo" data-role="bar" height="100" width="100"><desc>This is a test svg</desc><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red"></circle></svg>"}