# `ElementorexCms.Renderer`
[🔗](https://github.com/rocket4ce/elementorex_cms/blob/v0.1.0/lib/elementorex_cms/renderer.ex#L1)

Renders documents and nodes with the blocks of a registry.

`ElementorexCms.Components.document/1` is the usual entry point in templates;
this module is the engine underneath, plus `to_html/2` to get a string (emails,
caches, the editor canvas).

Every value reaches the blocks cast and sanitized again (see
`ElementorexCms.Block.assigns/2`), and documents are normalized before being
rendered, so a stored document cannot inject markup, script or CSS even if it
was edited by hand.

# `context`

```elixir
@spec context(keyword()) :: ElementorexCms.Renderer.Context.t()
```

A render context. Options: `:mode`, `:registry` (default
`ElementorexCms.Registry.default/0`) and `:data`.

# `render_node`

```elixir
@spec render_node(map(), ElementorexCms.Renderer.Context.t()) ::
  Phoenix.LiveView.Rendered.t() | String.t()
```

Renders one node (and its children) with its block.

# `to_html`

```elixir
@spec to_html(ElementorexCms.Document.t() | map(), keyword()) :: String.t()
```

HTML of a whole document (its `<style>` included) or of a single node, as a
string.

Options: `:mode`, `:registry`, `:data` (like `context/1`) and, for documents,
`:class`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
