| Blog | https://owaiskhan.me/blog |
| GitHub | https://github.com/owaiswiz |
| https://twitter.com/owaiswiz |
If you use VSCode and have a lot of View Components, configuring explorer.fileNesting might clean up your `app/components` in the explorer a lot:
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*_component.rb": "_${capture}_component_*.html.erb, ${capture}_component.html.erb, ${capture}_component.js, ${capture}_component_controller.js, ${capture}_component.scss"
},
I've always felt rendering ViewComponent with Rails is a bit too verbose.
Especially if you have namespaces. E.g:
render(Admin::Navigation::Item.new(label: 'Example'))
I've used a helper to make it nicer on 2 projects so far:
vc.admin.navigation.item(label: 'Example')
Maybe make it into a gem?
(Might seem a bit over-engineered on a first glance. But it's something that might be called 100s-1000s of time on a page, so had to make sure it's fast enough.