-
Notifications
You must be signed in to change notification settings - Fork 485
Add from to use_helpers to add macro like syntax #2034
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
Merged
joelhawksley
merged 23 commits into
ViewComponent:main
from
reeganviljoen:rv-add-helper-macro
Jun 20, 2024
Merged
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4bf833c
add: helpers macro
04a1ab0
refactor helpers macro
d0d6979
refactor helpers macro
f37e33c
add: kwargs tests
d63f5b4
add: documentation
a3ea509
add: changelog entry
54579ff
Merge branch 'main' into rv-add-helper-macro
reeganviljoen cd52c86
add: block test and use_helper singular method
3da4bcc
fix: ruby2_keywords warnings
49cc43a
add: singular documentation
fbec842
fix: linting
9bab5e2
Merge branch 'main' into rv-add-helper-macro
joelhawksley 36825ba
fix: linting
6dfa865
Merge branch 'main' into rv-add-helper-macro
reeganviljoen ec4a40a
fix: lint
0c37f4f
refactor: code
8d5e4ec
Merge branch 'main' into rv-add-helper-macro
reeganviljoen 3849f29
fix rails main tests
d5b8f1e
fix: linting
569c608
fix linting
946552e
fix: linting
1c25a4f
Apply suggestions from code review
joelhawksley 0c2ed75
Merge branch 'main' into rv-add-helper-macro
joelhawksley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/sandbox/app/components/use_helpers_macro_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <div class='helper__message'> | ||
| <%= message %> | ||
| </div> | ||
|
|
||
| <div class='helper__args-message'> | ||
| <%= message_with_args('macro helper method') %> | ||
| </div> | ||
|
|
||
| <div class='helper__kwargs-message'> | ||
| <%= message_with_kwargs(name: 'macro kwargs helper method') %> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class UseHelpersMacroComponent < ViewComponent::Base | ||
| use_helpers :message, :message_with_args, :message_with_kwargs, from: MacroHelper | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module MacroHelper | ||
| def message | ||
| "Hello helper method" | ||
| end | ||
|
|
||
| def message_with_args(name) | ||
| "Hello #{name}" | ||
| end | ||
|
|
||
| def message_with_kwargs(name:) | ||
| "Hello #{name}" | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_helperas 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