This PR fixes #6 and introduces a number of new features:
Elements are a new type of attribute
Elements can have content captured to them from the yielded component block
Elements can reside in a collection that gets appended to
Elements can have additional attributes
This allows for something like:
class Card < Components::Component
attribute :id
has_one :header
has_many :sections do
attribute :size
end
end
<%= component "card", id: "card-1", do |c| %>
<% c.header do %>
A header with some <em>captured</em> content
<% end %>
<% c.sections size: "large" do %>
A large captured section
<% end %>
<% c.sections size: "small" do %>
A small captured section
<% end %>
<% end %>
Or a navigation component:
class Navigation < Components::Component
has_many :items do
attribute :url
attribute :active, default: false
end
end
This PR fixes #6 and introduces a number of new features:
This allows for something like:
Or a navigation component:
Also adds some overdue unit tests.
Todo
NilClass
. Fix perhaps with a&.dup
.