Meteor template helper for detecting the active iron:router route
This package is based on the excellent zimme:iron-router-active package. After adding some features and modifying the original package, it ended up being mostly rewritten. I decided to release this as a separate package for people with similar use cases as myself.
A single template helper is exposed by this package: isActive
. Check the usage instructions below.
meteor add logandk:iron-router-active
Insert the isActive
helper either inside a class attribute or an #if
statement. Either a route or path must be specified.
The following options may be provided to the isActive
helper.
One of the route
/path
parameters must be specified. By default, the function will return active
if there is a match.
Use the className
parameter to override the default class name (active
).
Set the regex
parameter to true
in order to enable regular expression matching.
Set the inverse
parameter to true
in order to invert matching. This change the default to return disabled
if there is no match. This default can be changed using the className
parameter.
Just like the pathFor
helper in iron:router
, a data context can be specified. This will cause any parameters in the route url to be matched against the corresponding attributes of the context object. By default, the current template context is passed, so the first two examples below are identical.
MIT