Reputation: 4019
Reading the Discover Meteor
book (and many blogs) the following syntax is used:
Router.route('home', {
path: '/',
// ...
});
But the iron router github quick guide uses:
Router.route('/', {
name: 'home',
// ...
});
And I have even seen:
Router.route({
name: 'home',
path: '/',
// ...
});
Which is considered correct? How are number 1 and 2 separated from one another?
Upvotes: 1
Views: 42
Reputation: 22696
There is no "correct" syntax as they are all accepted by iron:router
, however, number 2 is arguably most commonly found because it's the one used in the guide after all.
Routing is all about URLs so I consider that defining a route by first indicating its path makes sense.
iron:router
can tell the difference between syntax 1 and 2 simply because the options object passed as second argument will likely contain path
or name
as properties, and it will assume that the first argument was the other one. If there's no name
or path
properties specified, it will assume the first argument is a path.
Upvotes: 1