isActivePath for route names
Closed this issue · 10 comments
I've been trying to get isActivePath to work for a route-group I've setup called dashboard
, for each individual view I have episodes
, comments
, users
etc. But I can't figure out how to reference these properly with isActivePath. For now I'm doing:
<li class="{{isActivePath regex='^dashboard|users'}}"><a href="{{pathFor 'dashboardUsers'}}">Users</a></li>
<li class="{{isActivePath regex='^dashboard|shows'}}"><a href="{{pathFor 'dashboardShows'}}">Shows</a></li>
<li class="{{isActivePath regex='^dashboard|episodes'}}"><a href="{{pathFor 'dashboardEpisodes'}}">Episodes</a></li>
<li class="{{isActivePath regex='^dashboard|comments'}}"><a href="{{pathFor 'dashboardComments'}}">Comments</a></li>
But I would prefer to use the routes name to use as a reference in isActivePath. Is this possible? Eg. {{isActivePath 'dashboardEpisodes'}}
currently this is not possible, but let me look into it.
@banglashi How would you define the routes then? Just using regex? Eg. is {{isActivePath regex='^dashboard|shows'}}
valid for a route that is defined as such:
var dashboardRoutes = FlowRouter.group({
middlewares: [hasDashboardAccess],
prefix: '/dashboard'
});
And then:
dashboardRoutes.route('/shows', {
subscriptions: function() {
this.register('shows', Meteor.subscribe('allShows'));
},
action: function() {
FlowLayout.render('layout', {nav: 'dashboardNavigation', main: 'dashboardShows'});
},
name: 'dashboardShows'
});
Hi @michaelevensen
I just updated the package to version 0.1.6. You can now define {{isActivePath name='dashboardEpisodes'}}. Since there have been many new additions to flow-router, like grouped and named routes I will have to revisit the whole package and start writing some tests. For now it should work for your use-case. I will keep you posted as soon as I have done the refactor.
Fantastic! Thanks so much for such quick turnaround.
Just wanted to let you know I've released version 2.0.0 of zimme:iron-router-active
under the new name zimme:active-route
in which I've added support for flow-router.
How do you feel about working together?
I'm thinking you could api.use('zimme:active-route@2.0.0);
and api.imply('zimme:active-route')
in this package and remove/move your {{isActivePath ...}}
functionality from this package.
This way when someone installs this package they get all your helpers and my 4 helpers, and also the 2 javascript helpers ActiveRoute.name(..)
and ActiveRoute.path(...)
Thoughts?
👍 ping me if you need any help
@zimme should be done. Let me know if you see any problems.
@michaelevensen There was a slightly change regarding your request on this ticket, just use isActiveRoute
instead of isActivePath
when working with named routes.
Looks ok 👍
Great, thanks @banglashi