Brix.Render (Brix v0.1.1)

Copy Markdown View Source

Render helpers for Phoenix LiveView. Dispatches sections to your app's function components by template name.

Summary

Functions

Renders child sections for a specific field. Use inside section components to render nested sections.

Renders a layout by dispatching its header sections, yielding the inner block, then dispatching its footer sections.

Resolves a media slug to its serving path.

Renders a single section by dispatching to the matching function component in module. Passes @fields, @children, and @module as assigns.

Renders a list of sections by dispatching each to the corresponding function component in module. The component function name matches the section's template name.

Functions

child_sections(assigns)

Renders child sections for a specific field. Use inside section components to render nested sections.

Example

def gallery(assigns) do
  ~H"""
  <div class="gallery">
    <h2>{@fields["title"]}</h2>
    <Brix.Render.child_sections module={@module} children={@children} field="slides" />
  </div>
  """
end

Attributes

  • module (:atom) (required)
  • children (:map) (required)
  • field (:string) (required)

layout(assigns)

Renders a layout by dispatching its header sections, yielding the inner block, then dispatching its footer sections.

Attributes

  • layout (:map) (required)
  • module (:atom) (required)

Slots

  • inner_block (required)

media_url(slug)

@spec media_url(String.t()) :: String.t()

Resolves a media slug to its serving path.

render_section(module, section)

Renders a single section by dispatching to the matching function component in module. Passes @fields, @children, and @module as assigns.

sections(assigns)

Renders a list of sections by dispatching each to the corresponding function component in module. The component function name matches the section's template name.

Attributes

  • sections (:list) (required)
  • module (:atom) (required)