Slots are blocks

The `item` method accepts a block, which is rendered in the navigation `li > a` tag.

Navigation component implementation
class Nav < Phlex::HTML
  def view_template(&content)
    nav(class: "main-nav") { ul(&content) }
  end

  def item(url, &content)
    li { a(href: url, &content) }
  end
end
Calling the navigation component
render Nav.new do |it|
  it.item("/") { "Home" }
  it.item("/about") { "About" }
  it.item("/contact") { "Contact" }
end
8 / 39