-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use partial and content_for to wrap components in style guide #88
base: master
Are you sure you want to change the base?
Use partial and content_for to wrap components in style guide #88
Conversation
Get Latest from DevNacho
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} The partial will use mv_content_for_name to retrieve that specific content_for value and display it within the wrapper.
The content_for block format (as well as trying partial layout: component_stub.meta_partial to use a block format with :yield) resulted in the rails server exiting with an error code. Removing the block seems to have solved the issue.
Added a bit of info about the partials to the readme
<%= render_component @component.name, component_stub.properties.clone %> | ||
<% else %> | ||
<% content_for_name = "mv_#{@component.name}_#{index}" %> | ||
<% content_for :"#{content_for_name}", |
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.
Could theoretically use a layout with yield as well... for some reason I can't use a block though... my server crashes if I use a block with content_for or render layout...
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.
Interesting... Yes, that would look much better, IMO. Passing a mv_content_for_name
feels kinda dirty.
Ideally this would be something like:
<%= render component_stub.meta_layout do %>
<%= render_component @component.name, component_stub.properties.clone %>
<% end %>
And we could generalize it more if we returned an empty partial (with just yield
) by default in MountainView::Stub#meta_partial
(and only override if specified), so we don't need the if component_stub.meta_partial.blank?
check.
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 like that idea a lot... but I have to figure out why using the render with a block, as above, causes the server to crash. Have you heard anything about that? I lean toward blaming windows :/ But it probably needs to work on windows, so I'd have to figure it out.
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 haven't heard anything about that :(
But if you want to push those changes that make your server crash either here or to a different branch, I'm more than happy to take a look and try to see if I can reproduce or not.
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! |
This worked on the mac, now retesting in windows.
Trying rename partial as layout and changing to the example provided in the PR comments, in the hopes it will solve the server crash thing. (also got rid of the pink and added a bit of padding lol)
Co-Authored-By: Esteban Pastorino <[email protected]>
So, with any code configuration I have tried (examples include: the current committed code, as well as On windows the server returns:
If I load the demo site on the Mac, the server returns:
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. |
|
||
Sometimes you may want to wrap extra content around the component in the style guide. For example, you may want to include a form tag around a custom form component without including the form tag in the component itself. You can do this by adding the key `partial` in the `mv_stub_meta`. |
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.
Needs to be rewritten
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? |
Sorry for the delayed reply. I have pointed mountain_view_demo at
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. |
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}" %>