drab v0.8.2 Drab.Config

Drab configuration related functions.

Configuration options:

:disable_controls_while_processing (default: true)

After sending request to the server, sender object will be disabled until it gets the answer. Warning: this behaviour is not broadcasted, so only the control in the current browser is going to be disabled.

:disable_controls_when_disconnected (default: true)

Shall controls be disabled when there is no connectivity between the browser and the server?

:events_to_disable_while_processing (default: ["click"])

Controls with those Drab events will be disabled when waiting for server response.

:events_shorthands (default: ["click", "change", "keyup", "keydown"])

The list of the shorthand attributes to be used in drab-controlled DOM object, ie: <drab-click="handler">. Please keep the list small, as it affects the client JS performance.

:socket (default: "/socket")

Path to the socket on which Drab operates.

:js_socket_constructor, (default: “require(“phoenix”).Socket”)

Javascript constructor for the Socket; more info in Drab.Client.

:drab_store_storage (default: :session_storage)

Where to keep the Drab Store - :memory, :local_storage or :session_storage. Data in the memory is kept to the next page load, session storage persist until browser (or a tab) is closed, local storage is kept forever.

:browser_response_timeout (default: 5000)

Timeout, after which all functions querying/updating browser UI will give up; integer in milliseconds, or :infinity.

:main_phoenix_app

A name of your Phoenix application (atom). If it is not set, Drab tries to guess it from from the mix.exs. Must be set when not using Mix.

:enable_live_scripts (default: false)

Re-evaluation of JavaScripts containing living assigns is disabled by default.

:live_conn_pass_through, (default: %{private: %{phoenix_endpoint: true}})

A deep map marking fields which should be preserved in the fake @conn assign. See Drab.Live for more detailed explanation on conn case.

:templates_path (default: “priv/templates/drab”)

Path to the user-defined Drab templates (not to be confused with Phoenix application templates, these are to be used internally, see Drab.Modal for the example usage). Must start with “priv/“.

:phoenix_channel_options (default: [])

An options passed to use Phoenix.Channel, for example: [log_handle_in: false].

:default_encoder *(default: Drab.Coder.Cipher)

Sets the default encoder/decoder for the various functions, like Drab.Browser.set_cookie/3

Link to this section Summary

Functions

Returns the config for current main Application

Returns any config key for current main Application

Returns all environment for the default main Application

Returns the Phoenix Application module atom

Returns the name of the client Phoenix Application

Returns configured Drab.Live.Engine Extension. String with dot at the begin

Returns the Endpoint of the client Phoenix Application

Returns Drab configuration for the given atom

Returns the PubSub module of the client Phoenix Application

Link to this section Functions

Link to this function app_config()
app_config() :: Keyword.t()

Returns the config for current main Application

iex> is_list(Drab.Config.app_config())
true
Link to this function app_config(config_key)
app_config(atom()) :: term()

Returns any config key for current main Application

iex> Drab.Config.app_config(:secret_key_base) |> String.length()
64
Link to this function app_env()
app_env() :: Keyword.t()

Returns all environment for the default main Application

iex> is_list(Drab.Config.app_config())
true
Link to this function app_module()
app_module() :: atom()

Returns the Phoenix Application module atom

iex> Drab.Config.app_module()
DrabTestApp
Link to this function app_name()
app_name() :: atom()

Returns the name of the client Phoenix Application

iex> Drab.Config.app_name()
:drab
Link to this function drab_extension()
drab_extension() :: String.t()

Returns configured Drab.Live.Engine Extension. String with dot at the begin.

Example, for config:

config :phoenix, :template_engines,
  drab: Drab.Live.Engine

it will return “.drab”

iex> Drab.Config.drab_extension()
".drab"
Link to this function ebin_dir()
ebin_dir() :: String.t()
Link to this function endpoint()
endpoint() :: atom()

Returns the Endpoint of the client Phoenix Application

iex> Drab.Config.endpoint()
DrabTestApp.Endpoint
Link to this function get(arg1)
get(atom()) :: term()

Returns Drab configuration for the given atom.

iex> Drab.Config.get(:templates_path)
"priv/custom_templates"

All the config values may be override in config.exs, for example:

config :drab, disable_controls_while_processing: false
Link to this function pubsub()
pubsub() :: atom() | no_return()

Returns the PubSub module of the client Phoenix Application

iex> Drab.Config.pubsub()
DrabTestApp.PubSub