-
Notifications
You must be signed in to change notification settings - Fork 354
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
add custom_control #289
add custom_control #289
Conversation
It seems like this PR is a different way of accomplishing the same thing as #301. Am I right? @ThomasSevestre @antpaw which do you think is the better solution? |
I don't like the name of the method, i prefer to just remove the private attribute form |
It all depends on your will to publish |
How does removing this method from private breaks the API? I think its not a major change, it will be the same as a new method was added? |
If the method becomes public, future changes to the method will break the API. |
As the de facto maintainer of this gem, I am concerned about breaking changes, but I am also concerned about support and usability of the API. For me, the method name I would prefer we make a new public method with a good, self-explanatory name. How we structure the implementation is less important: it could even just be a public alias of |
form_group_builder(name, options) do | ||
capture(&block) | ||
end | ||
end |
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.
Would this accomplish the same thing? Do we need the extract_options!
and capture
?
def custom_control(name, options={}, &block)
form_group_builder(name, options, &block)
end
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.
extract_options!
is not needed. I've copied static_control
to have the same ergonomy. It allows this kind of things:
= custom_control label: 'MyLabel' do
...
capture
is not needed since it is already done in form_group
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 see... So in order to support the example you described (custom_control label: 'MyLabel'
), then we do need extract_options!
. Right?
capture
is not needed since it is already done inform_group
Agreed. Can you update the PR to remove it?
@ThomasSevestre I'd still like merge this PR if you are interested. Could you review the latest code comments and provide an update? Thanks |
@mattbrictson Sorry for my late reply, I've removed |
Thanks! 🙇 |
static_control
wraps the displayed value in ap
tag.This is a problem in some edge use case, when you want to display an
ul
element.It leads to invalid HTML generation that is silently changed by erb / haml / slim.
This view (slim) :
Generate something like :
The new
custom_control
helper generates expected view :