Mau.Renderer (mau v0.8.0)

View Source

Renderer for the Mau template engine.

Handles rendering of AST nodes into output strings. For Group 1, only handles text node rendering.

Summary

Functions

Renders a template AST with the given context.

Renders an AST node to a string.

Functions

render(data, context, opts \\ [])

Renders a template AST with the given context.

Handles both single nodes and lists of nodes.

render_node(node, context, opts \\ [])

Renders an AST node to a string.

Handles text nodes and expression nodes with literal evaluation.

Examples

iex> Mau.Renderer.render_node({:text, ["Hello world"], []}, %{})
{:ok, "Hello world"}

iex> Mau.Renderer.render_node({:expression, [{:literal, ["hello"], []}], []}, %{})
{:ok, "hello"}

iex> Mau.Renderer.render_node({:expression, [{:literal, [42], []}], []}, %{})
{:ok, "42"}