Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doughsay/connect-active-tags
Connect/Express middleware for tracking which links should be active in a view or layout.
https://github.com/doughsay/connect-active-tags
Last synced: about 1 month ago
JSON representation
Connect/Express middleware for tracking which links should be active in a view or layout.
- Host: GitHub
- URL: https://github.com/doughsay/connect-active-tags
- Owner: doughsay
- Created: 2013-06-07T23:01:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-02T23:04:31.000Z (over 11 years ago)
- Last Synced: 2024-10-06T06:46:21.057Z (about 1 month ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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:
```javascript
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:
```jade
...
a(href='/', class=activeOn('home'))
...
```