Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rendering-values.md with example of how to return a component from a function #1966

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions guides/release/in-depth-topics/rendering-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ or via a property on some object
```handlebars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are trying to equate this file to the JS backing it then we should specify the filename for both. There is information in the styleguide on how to do this https://github.com/ember-learn/guides-source/blob/master/CONTRIBUTING.md#style-guide

<this.someComponent />
```
```ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any TypeScript in the guides (yet). There is a whole process that is underway to add a typescript version of the guides but until that is done then you should write all your backing JS as JS 👍

import { ComponentLike } from '@glint/template'; // only needed if you're using typescript
import MyOtherComponent from 'my-app/components/my-other-component';
import MySuccessComponent from 'my-app/components/my-success-component';

export default class MyComponent extends Component {
@tracked status: string;

get someComponent(): ComponentLike<MyComponentArgs> {
// if you're using typescript, any returned component must have been defined as
// class MyComponent extends Component<MyComponentArgs> {}
if (this.status == 'success') {
return MySuccessComponent;
} else {
return MyOtherComponent;
}
}
}
```
or via an argument passed to a component
```handlebars
<@someComponent />
Expand Down
Loading