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.
Summary
Functions
A render context. Options: :mode, :registry (default
ElementorexCms.Registry.default/0), :data, :sources (default
ElementorexCms.Sources.default/0), :params (the query params of the
page, for paginated loops) and, for documents that show one record (the
template of a product page…), :record with its :source (a key, a source
or a module; found from the record's schema when missing).
Renders one node (and its children) with its block.
HTML of a whole document (its <style> included) or of a single node, as a
string.
Functions
@spec context(keyword()) :: ElementorexCms.Renderer.Context.t()
A render context. Options: :mode, :registry (default
ElementorexCms.Registry.default/0), :data, :sources (default
ElementorexCms.Sources.default/0), :params (the query params of the
page, for paginated loops) and, for documents that show one record (the
template of a product page…), :record with its :source (a key, a source
or a module; found from the record's schema when missing).
@spec render_node(map(), ElementorexCms.Renderer.Context.t()) :: Phoenix.LiveView.Rendered.t() | String.t()
Renders one node (and its children) with its block.
@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, :sources, :record, :source and
:params (like context/1), :locale (the language of the texts the blocks add, see
ElementorexCms.I18n) and, for documents, :class.