Use partial and content_for to wrap components in style guide
Added the ability to have a partial in the meta. If partial exists, the component will be added to content_for with a name mv_#{component_name}_#{index} and the partial will be rendered instead of the component.
To include the component in the partial, you reference <%= content_for :"#{mv_content_for_name}" %>
Thanks for opening this!!
It's looking really good! I'd like to iterate a bit more on the implementation so it looks clean and follows some existing conventions. And would be really nice to have some integration tests for this, as it's not a trivial feature.
Let me know what you think!
Definitely more work is needed, but I wanted to get the proof of concept up. I'm really hung up on the server crashing when I use the block version. If you have any ideas for me there, I'd appreciate it.
It didn't occur to me to create a draft pull request, but if we have those as an option, we could shift this to a draft. I didn't see a way to change it, might have to close and re-open as draft.
No worries about the Draft PR, I still forget GH has that feature 😅 We can keep working here, no need to change or reopen.
Thanks again for working on this!
So, with any code configuration I have tried (examples include: the current committed code, as well as render :layout and content_for), if I have a block, mountain_view_demo crashes on load of the page with the block. I have access to a Mac at the moment, so I have tried this on both windows and Mac. Side note, The dummy app does not run on the windows machine I usually develop on, however, it does run on the Mac. I'm still trying to figure that one out. Having said that, the dummy app does not crash with this code on a Mac.
On windows the server returns:
Rendering C:/tools/ruby25/lib/ruby/gems/2.5.0/bundler/gems/mountain_view-c545a5ce9ba1/app/views/mountain_view/styleguide/show.html.erb within layouts/mountain_view
Process finished with exit code 3
If I load the demo site on the Mac, the server returns:
Started GET "/mountain_view/styleguide/header" for 127.0.0.1 at 2019-05-10 17:28:37 -0500 Processing by MountainView::StyleguideController#show as HTML Parameters: {"id"=>"header"} Rendering vendor/bundle/ruby/2.5.0/bundler/gems/mountain_view-619f13234e8a/app/views/mountain_view/styleguide/show.html.erb within layouts/mountain_view Rendered app/components/header/_test_layout.html.erb (2.2ms) Rendered vendor/bundle/ruby/2.5.0/bundler/gems/mountain_view-619f13234e8a/app/views/mountain_view/styleguide/show.html.erb within layouts/mountain_view (22.2ms) Completed 500 Internal Server Error in 36ms
#<Thread:0x00007f831a928e80@/Users/cpanus/.rbenv/versions/2.5.3/lib/ruby/2.5.0/webrick/server.rb:286 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): /Users/cpanus/Code/mountain_view_demo/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2/lib/action_dispatch/journey/router.rb:35:in `each': machine stack overflow in critical region (fatal)
Any tips, tricks or suggestions would be greatly appreciated. Also, iirc, I did try a very simple block on the main page of mountain_view_demo and it crashed there as well. Originally I thought this was a problem with using Windows, but that appears not to be the case. I can keep digging, but if you have any ideas, I'd be grateful for a pointer or two.
Hi, I'm sorry for the delay on reading this!! Can't find any obvious suspects in the code...
Can you provide more specific examples on how to reproduce what's failing locally? How are you getting those errors?
eg: checking out this branch and pointing mountain_view_demo to it? Or the dummy app inside?
Sorry for the delayed reply. I have pointed mountain_view_demo at
gem "mountain_view",
git: 'https://github.com/ChristineP2/mountain_view',
ref: '619f132'
I could not get the dummy app to work in windows. The dummy app does work on mac and does not err.
I get the errors with the DEMO app on both mac and windows.