view_component_storybook
view_component_storybook copied to clipboard
Enable rendering of nested components
This alters how slots are rendered on the view story page. The main change has the slots render themselves rather then evaluating the contents of the slots' block outside of the slots' context. This should allow stories to render nested slots which I don't believe is currently possible.
I'd like to understand a slightly larger use case than is shared in the tests. I have concern that this approach isn't going to work in some cases. The reason we do instance_eval
when rendering content_block (for the component or the slots) is that it allows the correct rendering of slots that use various view helpers etc. I think we'd want that to be true for nested components too?
@jklina @jonspalmer I believe you'd be able to combine both the use of helpers with nested components using the following addition to this PR:
https://github.com/dark-panda/view_component_storybook/commit/ec07f4261d16e6608d3562f7808819056358e8b7
@jklina @dark-panda I've added a slightly deeper example to the specs and included the suggested patch. I think we now get nested slots and helpers. Please take a look and see if these supports the use cases you'd expect. Happy to merge and release a new version if it does.
This looks great! Thank you and @dark-panda for taking this over the finish line! 👊
Cheers, I'll give this a shot soon to see how it looks on my end.