This package provide helpers for figuring out if some route or path is or isn't the currently active route.
Because of support for kadira:flow-router I've decided to rename
zimme:iron-router-active to zimme:active-route with version 2.0.0.
meteor add zimme:active-routeiron:routerkadira:flow-routermeteorhacks:flow-router(Deprecated)
If multiple routers are installed, the package will match against iron:router
routes first, then kadira:flow-router and lastly meteorhacks:flow-router.
Basic usage examples.
Template helper to check if the supplied route name matches the currently active route's name.
Returns either a configurable String, which defaults to 'active', or
false.
Template helper to check if the supplied path matches the currently active route's path.
Returns either a configurable String, which defaults to 'active', or
false.
Template helper to check if the supplied route name doesn't match the currently active route's name.
Returns either a configurable String, which defaults to 'disabled', or
false.
Template helper to check if the supplied path doesn't match the currently active route's path.
Returns either a configurable String, which defaults to 'disabled', or
false.
The following can be used by the template helpers as arguments.
- Data context, Optional.
StringorObjectwithname,pathorregex name, Optional.String. Only available forisActiveRouteandisNotActiveRoutepath, Optional.String. Only available forisActivePathandisNotActivePathregex, Optional.StringorRegExp
At least one of Data context, route or path need to be supplied.
Basic usage examples.
Helper to check if the supplied route name matches the currently active route's name.
Returns either true or false.
ActiveRoute.name('home');
// Returns true if current route's name is 'home'.
ActiveRoute.name(new RegExp('home|dashboard'));
// Returns true if current route's name contains 'home' or 'dashboard'.
ActiveRoute.name(/^products/);
// Returns true if current route's name starts with 'products'.Helper to check if the supplied path matches the currently active route's path.
Returns either true or false.
ActiveRoute.path('/home');
// Returns true if current route's path is '/home'.
ActiveRoute.path(new RegExp('users'));
// Returns true if current route's path contains 'users'.
ActiveRoute.path(/\/edit$/i);
// Returns true if current route's path ends with '/edit', matching is
// case-insensitiveThe javascript helpers accepts String or RegExp as an argument.
activeClass, Optional. Set toStringto change the defaultclassforisActiveRouteandisActivePathcaseSensitive, Optional. Set tofalseto make matching case-insensitivedisabledClass, Optional. Set toStringto change the defaultclassforisNotActiveRouteandisNotActivePathregex, Optional. Set totrueto make template helpers use regex matching with the following syntax,{{isActiveRoute '^home'}}
// Configure helpers globally
// The settings below are the package default settings
ActiveRoute.configure({
activeClass: 'active',
caseSensitive: true,
disabledClass: 'disabled',
regex: 'false'
});- SHOULD be backwards-compatible with
zimme:[email protected] ActiveRoute.configis an alias forActiveRoute.configureclassNameis an alias forclassin template helpers- This package supports javascript's
RegExp, here's some good info