drab v0.4.0 API Reference
Modules
Drab allows to query and manipulate the User Interface directly from the Phoenix server backend
The default engine used by EEx.
It includes assigns (like @foo
) and possibly other
conveniences in the future.
Examples
iex> EEx.eval_string("<%= @foo %>", assigns: [foo: 1])
"1"
In the example above, we can access the value foo
under
the binding assigns
using @foo
. This is useful because
a template, after being compiled, can receive different
assigns and would not require recompilation for each
variable set.
Assigns can also be used when compiled to a function:
# sample.eex
<%= @a + @b %>
# sample.ex
defmodule Sample do
require EEx
EEx.function_from_file :def, :sample, "sample.eex", [:assigns]
end
# iex
Sample.sample(a: 1, b: 2) #=> "3"
Browser related functions
Enable Drab on the browser side. Must be included in HTML template, for example
in web/templates/layout/app.html.eex
Drab Commander is a module to keep event handlers
Turns on the Drab Commander on the pages generated by this controller
Drab Module with the basic communication from Server to the Browser. Does not require any libraries like jQuery, works on pure Phoenix
Depreciated. To enable Drab, use Drab.Socket
in your UserSocket
module
Drab Module which contains function to launch Bootstrap Modals in the browser
Drab operates on websockets. To enable it, you should inject the Drab.Channel into your Socket module
(by default it is UserSocket
in web/channels/user_socket.ex
)
Enables Drab Waiter functionality - synchronous wait for browser events in the Commander handler function
Conveniences for translating and building error messages
A module providing Internationalization with a gettext-based API
Module with named helpers generated from DrabTestApp.Router
A module that keeps using definitions for controllers, views and so on
Generates a Drab commander
Exceptions
Raised when the browser encounters a JS error or the timeout for the current operation