0.1.1 • Published 11 years ago

active-tags v0.1.1

Weekly downloads
6
License
-
Repository
github
Last release
11 years ago

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'))
...