Component with translations#74
Component with translations#74joelhawksley merged 2 commits intoViewComponent:masterfrom juanmanuelramallo:component-with-translations
Conversation
- Proposing a solution for the shortcut issue #49
|
Hey @joelhawksley, I would appreciate your feedback on these changes! Thanks |
|
@juanmanuelramallo thanks for the PR! I'm hoping to have time to look this over today. |
| @@ -0,0 +1,6 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| class WithTranslations < ActionView::Component::Base | |||
There was a problem hiding this comment.
Might you be able to rename this to TranslationsComponent, to fit convention?
- Renamed `WithTranslations` to `TranslationsComponent`
joelhawksley
left a comment
There was a problem hiding this comment.
👏 this looks good. I'll likely due a light refactor to extract looking up the component's filename from the initialize method in a followup PR ❤️
| self.class.instance_method(:initialize) | ||
| .source_location | ||
| .first | ||
| .gsub(%r{(.*app/)|(.rb)}, "") |
There was a problem hiding this comment.
Is it possible that the regex substitution is not entirely correct?
app/components/editorb_component.rb will be changed to components/edit_component instead of the expected "components/editorb_component".
The regex should probably be (%r{(.*app/)|(\.rb)} or (%r{(.*app/)|(.rb$)}
There was a problem hiding this comment.
It seems you're right 😞
[1] pry(main)> 'app/components/editorb_component.rb'.gsub(%r{(.*app/)|(.rb)}, '')
=> "components/edit_component"There was a problem hiding this comment.
we discussed (me and eugen) and likely the combination of eugen's proposal is the safest: (%r{(.*app/)|(\.rb$)} (meaning a litteral .rb at the end)
There was a problem hiding this comment.
I'll create a PR for this fix
Solves issue #49
virtual_path