Skip to content

nathanhammond/ember-route-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 13, 2018
e1f39cd · Apr 13, 2018

History

35 Commits
Oct 19, 2017
Nov 20, 2015
Apr 13, 2018
Apr 13, 2018
Sep 11, 2015
Oct 22, 2016
Sep 11, 2015
Apr 13, 2018
Apr 13, 2018
Apr 13, 2018
Apr 13, 2018
Feb 5, 2016
Sep 14, 2015
Apr 13, 2018
Apr 13, 2018
Apr 13, 2018
Apr 13, 2018
Apr 13, 2018

Repository files navigation

ember-route-alias

Build Status npm version Ember Observer Score Code Climate

This Ember addon makes it easy to create multiple paths to the same route. By default it uses the same set of assets as the original route, but individual assets for each route can be overidden.

It also includes a simple {{#rel-link-to}} helper to make template reuse easier.

Warning: This addon monkey-patches the private Ember.RouterDSL#route method. As a result this addon can easily be broken by changes in Ember core. It is, however, used by a major product in the Ember ecosystem and will be kept up-to-date as best as possible.

Usage

ember install ember-route-alias

In app.js:

import RouteAliasResolver from 'ember-route-alias/mixins/route-alias-resolver';

App = Ember.Application.extend({
  /* ... */
  Resolver: Resolver.extend(RouteAliasResolver)
});

In router.js:

Router.map(function() {
  this.route('one', function() {
    this.route('a', function () {
      this.route('i', function() {});
      this.route('ii');
      this.route('iii');

      this.alias('alias-i', '/alias-i', 'i');
    });
    this.route('b');
    this.route('c');

    this.alias('alias-a', '/alias-a', 'a');
  });
  this.route('two');
  this.route('three');

  this.alias('alias-one', '/alias-one', 'one');
  this.alias('not-one', '/not-one', 'alias-one');
});

Electively you may add assets for any of the aliased routes by their name and it will load those assets instead. (The custom resolver is placed last in the queue.) For example, in templates/alias-one.hbs:

This template will be loaded instead of <pre>templates/one.hbs</pre>.

{{outlet}}

Running the sample application

The included sample application contains complete usage examples.

Running tests

  • npm run test

Pushing an updated sample app

ember github-pages:commit --message "Update demo app."
git push origin gh-pages:gh-pages