Sleeky.Ui.Compound (sleeky v0.0.3)

Provides with the ability to create compound views.

Compound views are simply views that depend on other views. This is useful in order to create layouts, eg:

defmodule MyApp.Ui.Layout do
  use Sleeky.View

  render do
    html do
      head do
      end
      body do
        div class: "main" do
          slot :main
        end
      end
    end
  end
end

then

defmodule MyApp.Ui.IndexPage do
  use Sleeky.View

  alias MyApp.Ui.Layout

  render do
    view Layout do
      main do
        h1 "It works!"
      end
    end
  end
end

In the above example the layout view defines a slot named :main.

Then the index page provides a value for that slot. The resolution phase, which happens at compile time, is in charge of recursively going through all these dependencies and replacing slot definitions by their values, until we obtain a new view definition that no longer has any dependencies.