Behaviour for defining reusable template blocks.
A block is a reusable EEx component that renders HTML. Blocks are invoked
in templates via the @block helper function:
<%= @block.(:recent_content, limit: 5) %>
<%= @block.(:toc) %>Assigns
The render/1 callback receives a map of assigns that always includes:
:site— the resolved site config map:content— the currentSayfa.Contentstruct (may benilfor list pages):contents— list of all site contents (for blocks likerecent_content):lang— the current language atom
Plus any additional options passed by the template caller.
Examples
defmodule MyApp.Blocks.Banner do
@behaviour Sayfa.Behaviours.Block
@impl true
def name, do: :banner
@impl true
def render(assigns) do
text = Map.get(assigns, :text, "Welcome!")
~s(<div class="banner">#{text}</div>)
end
end