-
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
Use dig in layouts guide ERB #629
Conversation
✅ Deploy Preview for lookbook-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Good catch @neanias! Thanks for the PR. About the docs, I'd stay it makes sense to improve the syntax there as well, what do you think @allmarkedup? |
I'm happy to change the others as part of this PR if that helps the sweep? |
If one uses the suggested layout for the ViewComponent default layout, navigating to `localhost:3000/rails/view_components` will throw an error due to the deeply nested nature of the Lookbook params hash. Using `dig` allows for safe access into the hashes without causing problems if any of the keys don't exist. This sweeps other instances of deep hash access. Hash#dig was introduced in Ruby 2.3, so will be available in all supported versions of Lookbook.
I think that's the main ones. I found |
@neanias yep that should be fine I think. Many thanks for your time with this, will merge now 👍 |
If one uses the suggested layout for the ViewComponent default layout, navigating to
localhost:3000/rails/view_components
will throw an error due to the deeply nested nature of the Lookbook params hash. Usingdig
allows for safe access into the hashes without causing problems if any of the keys don't exist.Hash#dig was introduced in Ruby 2.3, so will be available in all supported versions of Lookbook.
There's a few other instances of
params[:some][:deep][:key]
in the docs, but I thought this one may be a better target since it could cross the Lookbook boundary to ViewComponent.