Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Helper to add css class based on active route #4387
As discussed in #1822, #1849, and lately in manuelmitasch/ghost-admin-ember-demo@fba3ab0#commitcomment-5396470 there is currently no clean way to have an active css class (depending on active route) on a tag other than a link-to helper. This markup is used by bootstrap for example.
This double nesting is ugly.
We should add an
Other fancy usage
Sometimes, designers put classes on body to distinguish between styles for different templates. When the first parameter is no string (no route) it could lookup/add css classes from the handed property (eg. a views classNames property).
If you guys are happy with this proposal, I can try to implement a first draft.
Feb 17, 2014
@rjackson: I really like the neat little trick to create a binding between the
What I noticed through your solution is that
@manuelmitasch - I agree. This is more difficult than it needs to be, it was just an illustration of how you could do this now (that doesn't completely suck). I'd prefer to not have to reopen
I do not think that the presence of a custom component is an issue though. In your example you have to duplicate the route and args to the helper as well as the link-to that you would use. This is why I went with a custom component (so that the route name and args is only needed once in the template). To me this is EXACTLY what components are great for.
I have two specific PR's in mind for this:
FYI, Alex Speller posted a component that solves the Bootstrap issue. Very easy to use, less complex than this proposal.
@manuelmitasch - Thanks for the taking the time to submit this. As you can see we aren't terribly good at handling feature requests in the main repo's issues. Due to that, we have created the http://github.com/emberjs/rfcs repo to track proposals (as PR's) and requests for features (as issues). If you are still interested in pushing this forward, could you re-open this over there?