Skip to content

Instantly share code, notes, and snippets.

@benedikt
Last active February 3, 2019 12:52
Show Gist options
  • Select an option

  • Save benedikt/2a87d0ebb8e151cf1b6919c7db241cdb to your computer and use it in GitHub Desktop.

Select an option

Save benedikt/2a87d0ebb8e151cf1b6919c7db241cdb to your computer and use it in GitHub Desktop.

Revisions

  1. benedikt revised this gist Feb 3, 2019. 4 changed files with 11 additions and 2 deletions.
    4 changes: 3 additions & 1 deletion router.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,9 @@ const Router = EmberRouter.extend({

    Router.map(function() {
    this.route('route-a', function() {
    this.route('route-b');
    this.route('route-b', function() {
    this.route('route-d');
    });
    this.route('route-c');
    });
    });
    2 changes: 2 additions & 0 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    {{link-to "Route A" "route-a"}}
    {{link-to "Route B" "route-a.route-b"}}
    {{link-to "Route C" "route-a.route-c"}}
    {{link-to "Route D" "route-a.route-b.route-d"}}


    <br>
    <br>
    6 changes: 5 additions & 1 deletion templates.route-a.route-b.hbs
    Original file line number Diff line number Diff line change
    @@ -1 +1,5 @@
    {{#-in-element (query-selector "#application-outlet")}}Route B (rendered in application outlet){{/-in-element}}
    {{#-in-element (query-selector "#application-outlet")}}
    Route B (rendered in application outlet)

    <div class="outlet">{{outlet}}</div>
    {{/-in-element}}
    1 change: 1 addition & 0 deletions templates.route-a.route-b.route-d.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Route D (inside Route B)
  2. benedikt created this gist Feb 3, 2019.
    5 changes: 5 additions & 0 deletions controllers.application.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import Ember from 'ember';

    export default Ember.Controller.extend({
    appName: 'Ember Twiddle'
    });
    7 changes: 7 additions & 0 deletions helpers.query-selector.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import Ember from 'ember';

    export function querySelector([selector]) {
    return document.querySelector(selector);
    }

    export default Ember.Helper.helper(querySelector);
    16 changes: 16 additions & 0 deletions router.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import EmberRouter from '@ember/routing/router';
    import config from './config/environment';

    const Router = EmberRouter.extend({
    location: 'none',
    rootURL: config.rootURL
    });

    Router.map(function() {
    this.route('route-a', function() {
    this.route('route-b');
    this.route('route-c');
    });
    });

    export default Router;
    4 changes: 4 additions & 0 deletions routes.route-a.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    import Ember from 'ember';

    export default Ember.Route.extend({
    });
    4 changes: 4 additions & 0 deletions routes.route-a.route-b.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    import Ember from 'ember';

    export default Ember.Route.extend({
    });
    14 changes: 14 additions & 0 deletions styles.app.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    body {
    margin: 12px 16px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 12pt;
    }

    .outlet {
    border: solid 1px blue;
    padding: 10px;
    }

    #application-outlet {
    border-color: red;
    }
    9 changes: 9 additions & 0 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    {{link-to "Route A" "route-a"}}
    {{link-to "Route B" "route-a.route-b"}}
    {{link-to "Route C" "route-a.route-c"}}

    <br>
    <br>
    <div class="outlet" id="application-outlet">{{outlet}}</div>
    <br>
    <br>
    3 changes: 3 additions & 0 deletions templates.route-a.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Route A

    <div class="outlet">{{outlet}}</div>
    1 change: 1 addition & 0 deletions templates.route-a.route-b.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    {{#-in-element (query-selector "#application-outlet")}}Route B (rendered in application outlet){{/-in-element}}
    1 change: 1 addition & 0 deletions templates.route-a.route-c.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Route C (rendered in route-a outlet)
    19 changes: 19 additions & 0 deletions twiddle.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    {
    "version": "0.15.1",
    "EmberENV": {
    "FEATURES": {}
    },
    "options": {
    "use_pods": false,
    "enable-testing": false
    },
    "dependencies": {
    "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
    "ember": "3.4.3",
    "ember-template-compiler": "3.4.3",
    "ember-testing": "3.4.3"
    },
    "addons": {
    "ember-data": "3.4.2"
    }
    }