directify
Easier use of Director.js with Browserify, plus some added features.
Last updated 3 years ago by dguttman .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install directify 
SYNC missed versions from official npm registry.

Directify

Directify is a client-side router, actually it's pretty much Director.js (included) with some additional features/tweaks.

npm install directify

Example usage:

var router = require('directify');

// Usage: router(routingTable, targetElement, directorOpts);

var directorOpts = {
  notfound: function () {
    console.error('route not found')
  }
}

var routingTable = {
  '/': function() {
    return this.target.innerHTML = 'This is the root url.';
  },

  '/systems': function() {
    return this.target.innerHTML = "This is another path, it is: " + this.path;
  },

  '/parent': {
    '/sub/:json': function() {
      return this.target.innerHTML = "This path takes json params, they are: " + (JSON.stringify(this.params));
    }
  }
};

$(document).ready(function() {
  var targetElement = document.getElementById('main');
  router(routingTable, targetElement, directorOpts);
});

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

7 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 3
Last Day 1
Last Week 0
Last Month 5
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |