Ember.js v0.9.8.1

by pangratz666

HTML

<script src="https://github.com/downloads/pangratz/ember.js/ember-latest.js"></script>
<script type="text/x-handlebars" >
</script>

JavaScript

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

Ember.STRINGS = {
    '/all': '/alle',
    '/home/:id': '/zuhause/:id'
};

Ember.Route.reopen({
    init: function() {
        this._super();
        var route = this.get('route');
        if (route) this.set('route', route.loc());
    }
});

App.Router = Ember.Router.extend({
    location: 'none',

    root: Ember.Route.extend({
        index: Ember.Route.create({
            route: '/',
            showDashboard: Ember.Route.transitionTo('dashboard')
        }),

        dashboard: Ember.Route.create({
            route: '/home/:id'
        }),

        all: Ember.Route.create({
            route: '/all'
        })
    })
});

App.initialize();

var router = App.getPath('stateManager');

Ember.run(function() {
    router.route('/zuhause/42');
});

console.log(router.getPath('location').getURL(), "should be /zuhause/42");

Ember.run(function() {
    router.route('/alle');
});

console.log(router.getPath('location').getURL(), "should be /alle");