Ember Latest

The latest build of Ember.

HTML

<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script type="text/x-handlebars" data-template-name="application">
    <h1>ember-latest jsfiddle</h1>
    {{link-to 'Foo' 'foo'}}
    {{link-to 'Bar' 'bar'}}
    {{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
  <h2>Index Content:</h2>
  <ul>
  {{#each}}
      <li>{{firstName}} {{lastName}}</li>
  {{/each}}
   </ul>
</script>
<script type="text/x-handlebars" data-template-name="article">
    {{confirm}}<br />
  Article View
</script>

CSS

h1 { font-size: 1.6em; padding-bottom: 10px; }
h2 { font-size: 1.4em; }
ul { padding: 15px; font-size: 1.4em; color: green; }

JavaScript

App = Ember.Application.create({});

App.Router.map(function() {
    this.route('index', { path: '/' });
});

App.initializer({
    name: 'magicRoutes',
    //after: 'store',
    initialize: function(container, application) {
        // before you start your adapter lookup call
        // application.deferReadiness();
        // to prevent the application from initializing
        
        // in the success hook enumerate over your array of results..
        // in this case I'll just create foo as an example
        
        // do you store lookup and in the `finally` hook of the promise
        // application.advanceReadiness();
        
        // for simplicity, lets pretend this came back in your DS results
        var results = [
            { name: 'foo', type: 'article' }, 
            { name: 'bar', type: 'article' }
        ];
        
        App.Router.map(function() {
            results.forEach(function(key) {
                this.route(key.name);
            }, this);
        });
        
        results.forEach(function(key) {
            application.register('route:' + key.name, Ember.Route.extend({
                controllerName: key.type,
                viewName: key.type
            }));
            
            if(!container.has('view:' + key.type)) {
                application.register('view:' + key.type, Ember.View.extend({
                    templateName: key.type
                }));
            }
        }, this);
    }
});

App.IndexRoute = Ember.Route.extend({
  model: function(){
      return [
          {firstName: 'Kris', lastName: 'Selden'},
          {firstName: 'Luke', lastName: 'Melia'},
          {firstName: 'Formerly Alex', lastName: 'Matchneer'}
      ];
  }
});

App.ArticleController = Ember.Controller.extend({
    confirm: "Article Controller Property"
});