Skip to content

Instantly share code, notes, and snippets.

@kieran
Created June 26, 2010 23:47
Show Gist options
  • Save kieran/454457 to your computer and use it in GitHub Desktop.
Save kieran/454457 to your computer and use it in GitHub Desktop.
// in fresh/router.js
var Router = function () {
this.routes = [];
// ....
var Route = function(){
var name = "myRoute";
}
Route.prototype.toString = function() {
return("route: " + name);
}
}
// in fresh/index.js
global.ƒ = {};
var router = new (require('fresh/router')).Router();
Object.defineProperty( ƒ, "router", { value: router, writable: false, enumerable: true, configurable: false });
// include routes file, which populates the routes fine, adding them to ƒ.router.routes array
// ..... include some other stuff to the ƒ global object
sys.inspect(ƒ);
// =>
{ config:
{ environment: 'development'
, appRoot: '/Users/kieran/work/fresh/'
, logLevel: 'debug'
, growl: true
}
, log:
{ debug: [Function]
, info: [Function]
, warn: [Function]
, fatal: [Function]
, flush: [Function]
, empty: [Function]
}
, router:
{ routes: [ [Object], [Object] ] // <<<<<<<<<<<
, match: [Function]
, resource: [Function]
, first: [Function]
, all: [Function]
, url: [Function]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment