Hologram.Page behaviour (hologram v0.9.1)

Copy Markdown View Source

Summary

Callbacks

Handles a client-side action, typically triggered by a user interaction.

Handles a server-side command dispatched from the client.

Initializes the component and server structs on the server.

Returns a template in the form of an anonymous function that given variable bindings returns a DOM.

Functions

Casts page params to types specified with param/2 macro.

Defines page's layout metadata functions.

Accumulates the given param definition in params module attribute.

Returns the AST of code that registers params module attribute.

Defines page's route metadata functions.

Callbacks

action(atom, map, t)

(optional)
@callback action(atom(), map(), Hologram.Component.t()) :: Hologram.Component.t()

Handles a client-side action, typically triggered by a user interaction.

command(atom, map, t)

(optional)
@callback command(atom(), map(), Hologram.Server.t()) :: Hologram.Server.t()

Handles a server-side command dispatched from the client.

init(map, t, t)

Initializes the component and server structs on the server.

template()

@callback template() :: (map() -> list())

Returns a template in the form of an anonymous function that given variable bindings returns a DOM.

Functions

cast_params(params, page_module)

@spec cast_params(%{required(atom() | String.t()) => any()}, module()) :: %{
  required(atom()) => any()
}

Casts page params to types specified with param/2 macro.

layout(module, props \\ [])

(macro)
@spec layout(
  module(),
  keyword()
) :: Macro.t()

Defines page's layout metadata functions.

param(name, type, opts \\ [])

(macro)
@spec param(atom(), atom(), Hologram.Commons.Types.opts()) :: Macro.t()

Accumulates the given param definition in params module attribute.

register_params_accumulator()

@spec register_params_accumulator() :: Hologram.Compiler.AST.t()

Returns the AST of code that registers params module attribute.

route(path)

(macro)
@spec route(String.t()) :: Macro.t()

Defines page's route metadata functions.