Hologram.Template.Encoder protocol (hologram v0.1.0)
Link to this section Summary
Functions
Given VDOM template, generates virtual DOM template JS representation, which can be used by the frontend runtime to re-render the VDOM.
Link to this section Types
Specs
t() :: term()
Link to this section Functions
Link to this function
encode(vdom)
Specs
encode(Hologram.Typespecs.vdom_node() | [Hologram.Typespecs.vdom_node()]) :: String.t()
Given VDOM template, generates virtual DOM template JS representation, which can be used by the frontend runtime to re-render the VDOM.
Examples
iex> encode(%ElementNode{tag: "div", children: [%TextNode{content: "test}]})
"{ type: 'element', tag: 'div', attrs: {}, children: [{ type: 'text', content: 'test' }] }"