README.md in lite-component-1.0.8 vs README.md in lite-component-1.0.9
- old
+ new
@@ -260,9 +260,39 @@
end
end
```
+To add components as part of another component build a `block` and `yield` it in the component's view.
+
+```erb
+<%# app/views/components/_sidebar.html.erb %>
+
+<div class="sidebar">
+ <%= component("sidebar/navigation", locals: { class_name: "js-nav-links" }) do |c| %>
+ <% c.add("sidebar/navigation/link", locals: { text: "Link: 1", path: "/home", active: false }) %>
+ <% c.add("sidebar/navigation/link", locals: { text: "Link: 2", path: "/about", active: true }) %>
+ <% c.add("sidebar/navigation/link", locals: { text: "Link: 3", path: "/help", active: false }) do |n_c| %>
+ <% n_c.add("sidebar/something", locals: { test: "something" }) %>
+ <% end %>
+ <% end %>
+</div>
+```
+
+```erb
+<%# app/views/components/sidebar/_navigation.html.erb %>
+
+<div class="sidebar-navigation">
+ <%= c.yield %>
+</div>
+```
+
+```erb
+<%# app/views/components/sidebar/navigation/_link.html.erb %>
+
+<%= link_to(text, path, class: ("active" if l.active)) %>
+```
+
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).