One approach is to modify existing route options.
// Running it in Meteor.startup is only necessary because Telescope
// defines the route at startup
Meteor.startup(function () {
// Find a route by name
var route = Router.routes.posts_default;
// OR find a route by path
var route = Router.findFirstRoute('/');
// Override existing route options
_.extend(route.options, {
data: //...
// Other route options...
});
});
Another approach is to remove the route and recreate it.
Using a function which removes a route by its name,
function removeRouteByName (routeName) {
var routes = Router.routes;
var route = routes[routeName];
if (!route) return false; // Returns false if route is not found
// Remove route from Router
delete routes[routeName];
delete routes._byPath[route.path()];
var routeIndex = routes.indexOf(route);
if (routeIndex >= 0) routes.splice(routeIndex, 1);
// Remove route handler from MiddleWareStack
delete Router._stack._stack[routeName];
Router._stack.length -= 1;
return true; // Returns true when route is removed
}
We can remove and recreate the route by
// Running it in Meteor.startup is only necessary because Telescope
// defines the route at startup
Meteor.startup(function () {
removeRouteByName('posts_default');
Router.route('/', {
name: 'posts_default', // Use the same name
//Add your parameters...
});
});
Try running Telescope in this repository and you should see that the route /
has been changed.