Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Connect/Express middleware for tracking which links should be active in a view or layout.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

Active Tags

Description

Simple Express/Connect middleware to allow using tags to keep track of which nav links should be active in your views or layouts.

Install

npm install active-tags

Usage

It works by you pushing tags which are supposed to be "active" for a given route/action in your app code, and then using a helper method in your views.

In your app code:

activeTags = require('active-tags');

...

app.use(activeTags());

...

app.get('/', function(req, res) {
  res.pushTag('home');
  res.render('/home');
});

The helper method activeOn(tag) returns either the string 'active' or '', depending on if the supplied tag is active or not.

In your layout/view:

...
a(href='/', class=activeOn('home'))
...
Something went wrong with that request. Please try again.