Skip to content

Commit

Permalink
Merge pull request #9 from patricklx/support-outlet
Browse files Browse the repository at this point in the history
support outlet
  • Loading branch information
patricklx authored Mar 18, 2024
2 parents 2cb70d5 + fb46f9e commit 3fd60f8
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ class MyRouteComponent extends Component {
export default RoutableComponentRoute(MyRouteComponent);
```

You can also use outlets like this:

```gjs
// app/routes/my-route.gjs
import RoutableComponentRoute from 'ember-routable-component';
import Component from "@glimmer/component";
class MyRouteComponent extends Component {
<template>Hello, {{this.message}}. Why was I screaming? {{yield to='outlet'}}</template>
get message() {
return String(this.args.model).toUpperCase();
}
}
export default RoutableComponentRoute(MyRouteComponent);
```

With this feature, it eliminates most of the reasons for needing controllers,
other than for query params (which is another coherence gap Polaris would need
to address). We suggest exploring moving your non-QP controller logic into a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { precompileTemplate } from '@ember/template-compilation';
export default precompileTemplate("<this.Component @model={{this.model}} @controller={{this}} />");

export default precompileTemplate("<this.Component @model={{this.model}} @controller={{this}}><:outlet>{{outlet}}</:outlet></this.Component>");
3 changes: 3 additions & 0 deletions test-app/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Router.map(function () {
this.route('model-works', { path: 'model-works/:id' });
this.route('controller-works', { path: 'controller-works/:id' });
this.route('component-works', { path: 'component-works/:id' });
this.route('outlet-works',function() {
this.route('sub-route');
});
});
14 changes: 14 additions & 0 deletions test-app/app/routes/outlet-works.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Route from 'ember-routable-component';
import ControllerWorksController from 'test-app/controllers/controller-works';

interface Signature {
Args: {
controller: ControllerWorksController;
};
}

export default class ComponentWorksRoute extends Route<Signature>(
<template>hello, outlet: {{yield to='outlet'}}</template>,
) {

}
12 changes: 12 additions & 0 deletions test-app/app/routes/outlet-works/sub-route.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Route from 'ember-routable-component';
import ControllerWorksController from 'test-app/controllers/controller-works';

interface Signature {
Args: {
controller: ControllerWorksController;
};
}

export default Route<Signature>(
<template>hello sub route</template>,
);
12 changes: 12 additions & 0 deletions test-app/app/routes/sub-route/index.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Route from 'ember-routable-component';
import ControllerWorksController from 'test-app/controllers/controller-works';

interface Signature {
Args: {
controller: ControllerWorksController;
};
}

export default Route<Signature>(
<template>hello sub route</template>,
);

0 comments on commit 3fd60f8

Please sign in to comment.