Vaux (Vaux v0.4.0)
View SourceProvides functions to render Vaux components to html.
iex> defmodule HelloWorld do
...> import Vaux.Component
...>
...> attr :title, :string
...>
...> ~H"<h1>{@title}</h1>"vaux
...> end
iex> Vaux.render(HelloWorld, %{"title" => "Hello World"})
{:ok, "<h1>Hello World</h1>"}
Summary
Functions
Render a component to html
Same as render/3
, but raises an Vaux.RuntimeError
exception when an error is encountered
Types
Functions
@spec render(component :: module(), attrs :: attributes(), slots :: slot_content()) :: {:ok, iodata()} | {:error, Vaux.RuntimeError.t()}
Render a component to html
Accepts a map where keys are strings as attributes and a map where keys are atoms as slots.
Returns {:ok, iodata()}
or {:error, Vaux.RuntimeError.t()}
when an error
is encountered during rendering.
By default a string is returned, but when
config :vaux, render_to_binary: false
is set, an iolist is returned. Depending on the template complexity, this can give a small performance boost. Note that this config setting is evaluated at compile time.
@spec render!(component :: module(), attrs :: attributes(), slots :: slot_content()) :: iodata()
Same as render/3
, but raises an Vaux.RuntimeError
exception when an error is encountered