-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Rails view components #644
Conversation
Thanks, can you please add a spec? |
f7070fc
to
481a99e
Compare
View components are using a block to be able to render slots.
481a99e
to
4a28ea6
Compare
Done. I wasn't sure how to fake the component here, so I went with an anonymous class. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #644 +/- ##
=======================================
Coverage 94.31% 94.31%
=======================================
Files 17 17
Lines 457 457
=======================================
Hits 431 431
Misses 26 26 ☔ View full report in Codecov by Sentry. |
@budu can you please provide more information about what you are trying to do here and how this would be used? It's not clear if you are referring to view components as a general thing from Arbre's perspective or something specific to Rails. We'll also include this PR in the release notes so it would help to have background and examples on what this provides. Thank you. |
In my use case, it's to support ViewComponent's slots feature. For example: render BlogComponent.new do |component|
component.with_header do
link_to "My blog", root_path
end
BlogPost.all.each do |blog_post|
component.with_post do
link_to blog_post.name, blog_post.url
end
end
end This allows the ViewComponent was using a monkey patch before Rails 6.1. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
View components are using a block to be able to render slots.