View Source Hologram.Template.Renderer (hologram v0.2.0)
Summary
Functions
@spec render_dom(Hologram.Template.DOM.t(), Hologram.Template.Renderer.Env.t()) :: {String.t(), %{ required(String.t()) => %{module: module(), struct: Hologram.Component.t()} }}
Renders the given DOM.
Examples
iex> dom = {:component, MyModule, [{"cid", [text: "my_component"]}], []}
iex> render_dom(dom, %Env{})
{
"<div>state_a = 1, state_b = 2</div>",
%{"my_component" => %{module: MyModule, struct: %Component{state: %{a: 1, b: 2}}}}
}
@spec render_page( module(), %{required(atom() | String.t()) => any()}, Hologram.Commons.Types.opts() ) :: {String.t(), %{ required(String.t()) => %{module: module(), struct: Hologram.Component.t()} }}
Renders the given page.
Examples
iex> render_page(MyPage, %{param: "value"}, initial_page?: true)
{
"<div>full page content including layout</div>",
%{"page" => %{module: MyPage, struct: %Component{state: %{a: 1, b: 2}}}}
}