ember-learn / ember-learn/guides-source

Add more details to the section Contextual Components section

Open
#1,692 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
HTML
Stars
161
Forks
512
Avg merge
4d 9h
Merged PRs (30d)
4

Description

The current [Contextual Components section in the guides](https://guides.emberjs.com/release/in-depth-topics/patterns-for-components/#toc_contextual-components) is a little bit lacking and doesn't explain how contextual components are being used in the wider Ember community.

We have discussed this in the Learning team meeting and we have some suggestions on ways forward:

- add a description under the contextual components header linking to the component help api docs that has some content about nested usage
- the current Contextual Components section is a h2 so we could add 2 sub headers, one being the single-yield example that we currently have and adding a section header talking about a multi-yield example (using hash to return multiple components that can be used)

Here is a potential example that was provided by @nickschot that we could potentially use:

---

```
// parent-component.hbs

{{yield
CustomizedChildComponent=(component 'child-component' title="My Title")
}}

// child-component.hbs

{{@title}}


{{@body}}

```

When using it as follows:
```
// application.hbs

// rendered output, even though we did not pass @title explicitly


My Title


My Body Text


```

When passing/overriding @title:

```
// application.hbs

// rendered output, even though we did not pass @title explicitly


Custom Title


My Body Text


```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.