Builds documents in Elixir: for templates, seeds and tests.
import ElementorexCms.Builder
doc([
section([
block("heading", %{text: "Hello", level: "h1"}, style: %{"mobile" => %{"font-size" => "28px"}}),
block("text", %{text: "<p>Welcome!</p>"}),
block("button", %{label: "Start", url: "/start", icon: "arrow-right"})
])
])Props get the defaults of their block, so only what differs needs to be given.
Pass registry: to build with a custom registry.
Dynamic content: loop/4 repeats its children for the items of a source, and
dynamic: binds props to fields of the item (see ElementorexCms.Dynamic):
loop("products", [
block("card", %{title: "Product", button_label: "View"},
dynamic: %{
title: "name",
image: "image_url",
badge: [field: "price", before: "$", format: "number", decimals: 0],
button_url: "@url"
}
)
], %{limit: 6, columns: "3"})
Summary
Functions
A node of type. Options: :id, :children, :style (per state), :attrs
(Advanced settings), :dynamic (prop → field key or binding settings) and
:registry.
A grid whose columns are the given lists of children (one container per column).
A flex container with these children.
A document with these root children.
A Loop grid (ElementorexCms.Blocks.Loop) of the source with key source:
children are the content of one item, repeated for each.
A section with these children.
Functions
A node of type. Options: :id, :children, :style (per state), :attrs
(Advanced settings), :dynamic (prop → field key or binding settings) and
:registry.
A grid whose columns are the given lists of children (one container per column).
A flex container with these children.
@spec doc([map()], keyword()) :: ElementorexCms.Document.t()
A document with these root children.
A Loop grid (ElementorexCms.Blocks.Loop) of the source with key source:
children are the content of one item, repeated for each.
A section with these children.