Breeze.Component (Breeze v0.5.0)

Copy Markdown View Source

Template and component support shared by Breeze views and standalone components.

Use Breeze.Component when a module needs ~H, attributes, slots, assigns, and component definitions without implementing the Breeze.View lifecycle.

Summary

Types

Assigns passed to a view or function component.

Compiled template output returned by the ~H sigil.

Runtime slot entry generated by Breeze.Template

Functions

Merge values into term.assigns, or into a plain assigns map inside a component function.

Declares an attribute for the next function component.

Declares an attribute for the next function component.

Render a slot value using empty assigns.

Render a slot value with assigns passed to the slot render function.

Compiles a Breeze template from an ~H sigil.

Declares a slot for the next function component.

Declares a slot for the next function component.

Types

assigns()

@type assigns() :: map()

Assigns passed to a view or function component.

rendered()

@type rendered() :: term()

Compiled template output returned by the ~H sigil.

slot_entry()

@type slot_entry() :: %{
  optional(atom()) => term(),
  __breeze_slot__: (map() -> iodata())
}

Runtime slot entry generated by Breeze.Template

Functions

assign(term, values)

@spec assign(map(), Enumerable.t()) :: map()

Merge values into term.assigns, or into a plain assigns map inside a component function.

attr(name, type)

(macro)

Declares an attribute for the next function component.

attr(name, type, opts)

(macro)

Declares an attribute for the next function component.

Options include :required, :default, and :doc.

render_slot(slot)

@spec render_slot(nil | slot_entry() | [slot_entry()]) :: binary()

Render a slot value using empty assigns.

Accepts nil, a single slot entry, or a list of slot entries.

render_slot(slots, assigns)

@spec render_slot(nil | slot_entry() | [slot_entry()], map() | keyword() | nil) ::
  binary()

Render a slot value with assigns passed to the slot render function.

sigil_H(arg, modifiers)

(macro)

Compiles a Breeze template from an ~H sigil.

slot(name)

(macro)

Declares a slot for the next function component.

slot(name, opts)

(macro)

Declares a slot for the next function component.

Use a do block to declare attributes accepted by each slot entry. Options include :required and :doc.