-
Notifications
You must be signed in to change notification settings - Fork 444
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 from to use_helpers to add macro like syntax #2034
Add from to use_helpers to add macro like syntax #2034
Conversation
@joelhawksley @camertron @Spone it seems Rails main is broken again, I will investigate a fix tomorrow evening |
@joelhawksley @boardfish @camertron I know I haven't created an issue and I am mostly looking for any feedback on this, I feel that this makes this api largely more complete and fits its purpose of making the usage of helpers more explicit. 🙏 |
docs/guide/helpers.md
Outdated
|
||
```ruby | ||
class UserComponent < ViewComponent::Base | ||
use_helpers :icon, from: IconHelper |
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.
I guess it would make sense to support the singular form use_helper
as well?
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.
@Spone I have added this recommendation, as it seems like a great fit
@joelhawksley any thoughts |
@reeganviljoen - @camertron and I think this generally looks good, mind getting CI green? |
@joelhawksley I will find time tomorrow to fix it |
@joelhawksley I was able to get CI green by reverting #2039 , in the interesting of not opening another pr I included it here |
What are you trying to accomplish?
use_helepers
is powerful but as @joelhawksley mentioned in #1987So this is my attempt at adding a macro syntax by allowing helpers to be defined from specific helper modules
What approach did you choose and why?
I had two make use of two private methods one for the usage of defining a method from
__vc_original_view_context
or one from a specified module witch requires some more complex meta programming to change the ownership of the method to the component.