View Source Migrating from 0.10 to 0.11

Most of the changes in this release are related to tweaking Temple's component model to align with HEEx & Surface.

Rendering Slots

Slots are now available as assigns in the component and are rendered as such.

Before

def my_component(assign) do
  temple do
    span do
      slot :a_slot
    end
  end
end

After

def my_component(assign) do
  temple do
    span do
      slot @a_slot
    end
  end
end

:default slot has been renamed to :inner_block

The main body of a component has been renamed from :default to :inner_block.

Note: The "after" example also includes the necessary change specified above.

Before

def my_component(assign) do
  temple do
    span do
      slot :default
    end
  end
end

After

def my_component(assign) do
  temple do
    span do
      slot @inner_block
    end
  end
end

Passing data into slots

The syntax for capturing data being passed from the call site of a slot to the definition of a slot (or put another way, from the definition of a component to the call site of the component) has changed.

You now capture it as the value of the :let! attribute on the slot definition.

Before

def my_component(assign) do
  temple do
    c &my_component/1 do
      slot :a_slot, %{some: value} do
        "I'm using some #{value}"
      end
    end
  end
end

After

def my_component(assign) do
  temple do
    c &my_component/1 do
      slot :a_slot, let!: %{some: value} do
        "I'm using some #{value}"
      end
    end
  end
end