Support required: true
for renders_one slots
#1861
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi everyone, first of all thanks for the amazing work! I really love working with view_component!
I'm very new to the project and hope I can contribute to this project. Looking forward to any feedback.
What are you trying to accomplish?
Trying to solve the issue described in #614
What approach did you choose and why?
Add
required
option torenders_one
to indicate that there is a default slot to be rendered, which automatically applies lambda options. This only works with lambda or Component slots (and not for passthrough slots). It can be used with polymorphic slots but exactly one specific option can be required, otherwise an error is shown.This is just my first attempt and probably a lot of fine tuning is needed as this project is used by many people.
Anything you want to highlight for special attention from reviewers?
I added a new method
__vc_before_render
to theBase
class in order to register a method called from theSlotable
module. This way I was able to add defaults to the slots beforebefore_render
is called. I'm not sure if this is the best approach yet, but I'm happy to get any feedback.