emberjs/ember.js — pull request #1925 by carlitux (2013-01-30 01:30:02+00:00)
Title: Support namespaces in router definition map.

Hi Guys,

From my previous PR https://github.com/emberjs/ember.js/pull/1895, suggestion from @wycats .and from @stefanpenner.

As many of developer I decided to user :: as a resolver of namespaces.

Here is a simple example how should work.

window.App = Em.Application.create({
VERSION: '1.0.0',
LOG_TRANSITIONS: true
});

App.ApplicationController = Em.Controller.extend({});
window.Beta = Em.Namespace.create({
VERSION: '1.0.0'
});

Beta.RegistrationView = Em.View.extend({
template: Em.TEMPLATES['beta.registration'],
templateName: 'beta/registration'
});

Beta.RegistrationController = Em.ObjectController.extend({
title: "Registra tu email"
});

Beta.RegistrationRoute = Em.Route.extend();

App.Router.map(function() {
this.namespace(Beta, function() {
this.route("registration", {
path: "/beta/registration"
});
});
});

App.IndexRoute = Em.Route.extend({
redirect: function() {
this.transitionTo('Beta::registration');
}
});

for transition we should use Namespace::name to avoid collapse with others. Namespaces is added in deep unless we call namespace with another namespace object or only the callback to user App object.

NOTE: Nested namespaces is not supported the reason is for nested namespace toString method returns undefined.