-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fix rendering of partials in previews #606
Conversation
…rendering of partials in previews
✅ Deploy Preview for lookbook-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hey @liram11 this is fantastic, thank you so much for your work on this! And sorry I've taken a while to get to this. I'm going to check it out in more detail now but at first glance it looks great. To be honest the only thing I'm unsure about is whether this should actually be enabled by default as I think the current behaviour is really a bug. Whilst in theory this is a potentially breaking change I'm not sure I can think of any real world example where people would be relying on the current behaviour - would you agree? I'm tempted to default to enabling this by default whilst giving people the option to disable it if there is some reason they may need to.
Honestly, I'm pretty embarrassed about the state of the tests and test setup at the moment. Any additions or improvements would be most welcome but you might find it a bit of an uphill struggle! |
@liram11 It looks like the tests are failing for Rails 6.0 (which doesn't have the |
Hey @allmarkedup, Thanks a lot for taking a look at that!
I have the same feeling about that. To be honest, I was thinking about making this a default behavior but decided to get some initial feedback before introducing it. Since we agree on that - let me change it to be a default behavior.
Sure, I'll take a look. I should have some time today. |
Understood, I'll do some experiments with that later and will share the results in case anything sensible comes out😉 |
Fantastic - in future versions we may be able to remove the config option altogether but it's good to have that for now just in case.
Thank you! Much appreciated 🙂 |
…nfig option by default
Hey @allmarkedup, I changed the default behavior of the new option - now it is enabled by default. I also restructured the tests a bit. Now they should work fine even if some |
@liram11 Fantastic, thank you - this is looking great now. And I appreciate you taking the time to update the config documentation to include this new option too. I've just given it a spin and I can't see any issues so I'm going to merge this in and get it out in the next release. Thanks again for your contribution! |
@liram11 I've just released v2.3.0 that includes this change, much appreciated! |
Nice! I'll upgrade it in my project soon. Thank you, Mark! |
This PR adds a setting to the Lookbook config which allows disabling automatic prefixing of partials on the ActionView layer.
Motivation / Background
Rendering partials in Lookbook 2.2.2 using ActionView short-hand syntax
render @users
fails with the following error:In the error above ActionView automatically adds a
lookbook
prefix to the partial name which makes no sense in the context of lookbook.A similar issue was described in #560.
Details
This issue can be fixed by modifying the
ActionView::Base.prefix_partial_path_with_controller_namespace
ActionView setting during the rendering.I noticed the same case with
ActionView::Base.annotate_rendered_view_with_filenames
inActionViewAnnotationsHandler
and decided to extract both cases intoActionViewConfigHandler
class.Additional information
The new option is disabled by default so it wouldn't affect the default lookbook behavior.
Also, I was thinking of adding some integrational tests based on the dummy app. But I decided not to do that for now because It may require adding a db layer to the dummy app (to test
render @users
case). Let me know if it can be valuable and I'll do some experiments in a separate PR.