-
Notifications
You must be signed in to change notification settings - Fork 81
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
added no_container option to link_to helper #114
base: master
Are you sure you want to change the base?
Conversation
fixed side-efect of removing :no_container option from args added spec
Btw interesting thing the expect(:link_to).to generate html Confused me for a moment, before I realized it's a custom matcher. |
@Incanus3 before proceeding with this PR, could you show me a real example where you need this kind of customization? Thanks! |
Also… I think this option should be on the wrapping |
= nav do
- categories.each do |category|
%li{ class: active_if(selected_category == category) }
= link_to category.capitalize, events_path(category: category), no_container: true ( and you're right, the option should probably be on nav, but the container is being added in the link_to helper, so it seemed like the easiest thing to do. |
@Incanus3 Did you know that bh already sets the |
I do, but that's not flexible enough for my (and presumably other's) needs. The problem here is (among others), that when I first come to this page with category tabs, there's no category param, so the first tab is not highlighted. I cound of course add the param there, but that would mean that every link to that page needs to add the category param for it to be correctly highlighted. |
If I understand correctly, your nav links are something like
and you would live one of the links to be For instance, if you are in the page |
ad 1st paragraph: exactly. ad 2nd one: I don't override the url param by setting |
also, I'd like the first tab to be default, but don't want every |
Hello @Incanus3 – I think the case you are making is very custom. You want to set the In the most general case, that is an "unexpected" behavior… the You can definitely do that in your code, but I don't see this as something worth generalizing to the bh gem. The solution for your case is quite simple: do not use the Makes sense? |
Well, I'd agree that wanting the active class on a link that's realy different from the current page would be "unexpected". But I think that the latter case I mentioned (making the first tab default, thus '/events' ~= '/events?category=first_category') is quite common and in case of '/events' I need to highlight the first tab manually. Also, I think this option is not that much added code for greater flexibility. Of course, your suggested solution would work, but the reason I use bh is exactly so I don't need to do this. It's not just that I need to write a few more characters, but the view is much more readable when using the helper. |
this way, one can manually create (and customize) the surrounding li container inside nav or dropdown and tell link_to not to create it