Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

reeganviljoen
Copy link
Collaborator

What are you trying to accomplish?

use_helepers is powerful but as @joelhawksley mentioned in #1987

I think we might be better off having this be a macro folks can set on a component, likely on their ApplicationComponent.

So 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.

@reeganviljoen
Copy link
Collaborator Author

@joelhawksley @camertron @Spone it seems Rails main is broken again, I will investigate a fix tomorrow evening

@reeganviljoen
Copy link
Collaborator Author

reeganviljoen commented May 30, 2024

@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. 🙏


```ruby
class UserComponent < ViewComponent::Base
use_helpers :icon, from: IconHelper
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

@reeganviljoen reeganviljoen requested a review from Spone June 4, 2024 15:22
@reeganviljoen
Copy link
Collaborator Author

@joelhawksley any thoughts

@joelhawksley
Copy link
Member

@reeganviljoen - @camertron and I think this generally looks good, mind getting CI green?

@reeganviljoen
Copy link
Collaborator Author

@joelhawksley I will find time tomorrow to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants