Skip to content

Commit f554005

Browse files
authored
Merge branch 'master' into use-shikiji
2 parents 0acf5f3 + 7c44328 commit f554005

File tree

526 files changed

+34181
-6690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

526 files changed

+34181
-6690
lines changed

guides/release/components/block-content.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,98 @@ We can yield back multiple values as well, separated by spaces.
322322
</BlogPost>
323323
```
324324

325+
## Named Blocks
326+
327+
If you want to yield content to different spots in the same component, you can use named blocks. You just need to specify a name for the yielded block, like this:
328+
329+
```handlebars
330+
{{yield to="somePlace"}}
331+
```
332+
333+
You could also want to pass some values. This is the same process as the default `yield`, but you just have to pass `to` as the last argument. An example would be the popover:
334+
335+
```handlebars {data-filename=app/components/popover.hbs}
336+
<div class="popover">
337+
<div class="popover__trigger">
338+
{{yield this.isOpen to="trigger"}}
339+
</div>
340+
{{#if this.isOpen}}
341+
<div class="popover__content">
342+
{{yield to="content"}}
343+
</div>
344+
{{/if}}
345+
</div>
346+
```
347+
348+
Without named blocks, we would certainly have to pass components as `args` to the popover. But this is much more practical!
349+
350+
Here’s how we would call our named blocks as a consumer:
351+
352+
```handlebars
353+
<Popover>
354+
<:trigger as |open|>
355+
<button type="button">Click to {{if open "close" "open"}} the popover!</button>
356+
</:trigger>
357+
<:content>
358+
This is what is shown when I'm opened!
359+
</:content>
360+
</Popover>
361+
```
362+
363+
We know the state of the popover because we passed it as an argument to the `yield`. To access its value, use the block parameters at the named block scope. It will not be accessible at the `Popover` level, so if you want the value to be available for all the blocks, you will have to pass it for each of them.
364+
365+
Rendering the previous code example would give this as result:
366+
367+
```html
368+
<!-- rendered -->
369+
<div class="popover">
370+
<div class="popover__trigger">
371+
<button type="button">Click to close the popover!</button>
372+
</div>
373+
<div class="popover__content">
374+
This is what is showed when I'm opened!
375+
</div>
376+
</div>
377+
```
378+
379+
Don't worry, you can also still use `yield` by itself, and mix it with named blocks. Let’s take a card example:
380+
381+
```handlebars {data-filename=app/components/card.hbs}
382+
<div class="card">
383+
{{#if (has-block "title")}}
384+
<div class="card__title">
385+
{{yield to="title"}}
386+
</div>
387+
{{/if}}
388+
<div class="card__content">
389+
{{yield}}
390+
</div>
391+
</div>
392+
```
393+
394+
A yielded block without a name is called `default`. So to access it, it’s like any other named blocks.
395+
396+
```handlebars
397+
<Card>
398+
<:title>
399+
<h3>It's nice to have me. Sometimes</h3>
400+
</:title>
401+
<:default>
402+
The card content will appear here!
403+
</:default>
404+
</Card>
405+
```
406+
407+
The title being optional when you create a card, you can use the `(has-block)` helper with the named block by adding its name as a first parameter. That means you could also create this card:
408+
409+
```handlebars
410+
<Card>
411+
I don't want any title, and I only have a default content!
412+
</Card>
413+
```
414+
415+
As you are not using named blocks, you can simply yield the content you would like to add, which becomes the default yield block.
416+
417+
418+
325419
<!-- eof - needed for pages that end in a code block -->

guides/release/configuring-ember/configuring-ember-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
In addition to configuring your app itself, you can also configure Ember CLI.
22
These configurations can be made by adding them to the `.ember-cli` file in your application's root. Many can also be made by passing them as arguments to the command line program.
33

4-
For example, a common desire is to change the port that Ember CLI serves the app from. It's possible to pass the port number from the command line with `ember server --port 8080`. To make this configuration permanent, edit your `.ember-cli` file like so:
4+
For example, a common desire is to change the port that Ember CLI serves the app from. It's possible to pass the port number from the command line with `ember server --port 8080`, if you want to pass the port to your `npm start` script you would pass it with an extra `--` like this: `npm start -- --port 8080`. To make this configuration permanent, edit your `.ember-cli` file like so:
55

66
```json
77
{

guides/release/getting-started/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Let's make sure everything is working properly.
5151

5252
```bash
5353
cd ember-quickstart
54-
ember serve
54+
npm start
5555
```
5656

5757
After a few seconds, you should see output that looks like this:

guides/release/testing/index.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ You have a few options for running tests.
1616

1717
First, you can run the test suite by entering the command `ember test`, or `ember t`, in your terminal. This will run the suite just once.
1818

19-
Suppose, instead, you want the suite to run after every file change. You can enter `ember test --server`, or `ember t -s`.
20-
21-
Lastly, if you are already running a local development server (through `ember server`), you can visit the `/tests` URI. This will render the `tests/index.html` template.
19+
Running a local development server (through `npm start`), you can visit the `/tests` URI. This will render the `tests/index.html` template. This will also auto-update as you are changing files in your app.
2220

2321
```bash
2422
# Run all tests once
2523
ember test
2624
ember t
27-
28-
# Run all tests after every file change
29-
ember test --server
30-
ember t -s
3125
```
3226

3327
### How to Filter Tests
@@ -38,23 +32,23 @@ The `--module` option allows you to select a **module**—a group of tests that
3832

3933
```bash
4034
# Button component example
41-
ember test --server --module="Integration | Component | simple-button"
35+
ember test --module="Integration | Component | simple-button"
4236

4337
# Run tests for a location service
44-
ember t -s -m="Unit | Service | location"
38+
ember t -m="Unit | Service | location"
4539
```
4640

4741
The `--filter` option is more versatile. You can provide a phrase to match against the modules and test descriptions. A test description is what appears in `test()` in QUnit.
4842

4943
```bash
5044
# Button component example
51-
ember test --server --filter="should show icon and label"
45+
ember test --filter="should show icon and label"
5246

5347
# Test everything related to your dashboard
54-
ember t -s -f="Dashboard"
48+
ember t -f="Dashboard"
5549

5650
# Run integration tests
57-
ember t -s -f="Integration"
51+
ember t -f="Integration"
5852
```
5953

6054
In QUnit, you can exclude tests by adding an exclamation point to the beginning of the filter, e.g. `ember test --filter="!Acceptance"`.

guides/release/testing/testing-application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ During the development of your tests or when you refactor your application's cod
148148
To try them out, do the following steps:
149149

150150
1. Add `await pauseTest();` in your test code.
151-
2. Run `ember server`.
151+
2. Run `npm start`.
152152
3. Visit `http://localhost:4200/tests` in your browser
153153

154154
When the execution of the test come upon `await pauseTest()`, the test will be paused, allowing you to inspect the state of your application.

guides/release/testing/testing-components.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ module('Integration | Component | pretty-color', function(hooks) {
7171
setupRenderingTest(hooks);
7272

7373
test('should change colors', async function(assert) {
74-
assert.expect(1);
75-
7674
// set the outer context to red
7775
this.set('colorValue', 'red');
7876

@@ -102,8 +100,6 @@ module('Integration | Component | pretty-color', function(hooks) {
102100
setupRenderingTest(hooks);
103101

104102
test('it renders', async function(assert) {
105-
assert.expect(2);
106-
107103
// set the outer context to red
108104
this.set('colorValue', 'red');
109105

@@ -129,8 +125,6 @@ module('Integration | Component | pretty-color', function(hooks) {
129125
setupRenderingTest(hooks);
130126

131127
test('it renders', async function(assert) {
132-
assert.expect(2);
133-
134128
this.set('colorValue', 'orange');
135129

136130
await render(hbs`<PrettyColor @name={{this.colorValue}} />`);
@@ -189,8 +183,6 @@ module('Integration | Component | magic-title', function(hooks) {
189183
setupRenderingTest(hooks);
190184

191185
test('should update title on button click', async function(assert) {
192-
assert.expect(2);
193-
194186
await render(hbs`<MagicTitle />`);
195187

196188
assert.equal(this.element.querySelector('h2').textContent.trim(), 'Hello World', 'initial text is hello world');
@@ -241,8 +233,9 @@ export default class CommentFormComponent extends Component {
241233
```
242234

243235
Here's an example test that asserts that the specified `externalAction` function is invoked when the component's internal `submitComment` action is triggered by making use of a test double (dummy function).
244-
`assert.expect(1)` at the top of the test makes sure that the assertion inside the
245-
external action is called:
236+
The value from the external action is captured in a shared variable (if and when it is called),
237+
so that it can be explicitly asserted directly in the test function at the time where we
238+
expect the closure action to have been called.
246239

247240
```javascript {data-filename="tests/integration/components/comment-form-test.js"}
248241
import { module, test } from 'qunit';
@@ -254,12 +247,10 @@ module('Integration | Component | comment-form', function(hooks) {
254247
setupRenderingTest(hooks);
255248

256249
test('should trigger external action on form submit', async function(assert) {
257-
assert.expect(1);
258-
259250
// test double for the external action
260-
this.set('externalAction', (actual) => {
261-
let expected = { comment: 'You are not a wizard!' };
262-
assert.deepEqual(actual, expected, 'submitted value is passed to external action');
251+
let actual;
252+
this.set('externalAction', (data) => {
253+
actual = data;
263254
});
264255

265256
await render(hbs`<CommentForm @submitComment={{this.externalAction}} />`);
@@ -269,6 +260,9 @@ module('Integration | Component | comment-form', function(hooks) {
269260

270261
// click the button to submit the form
271262
await click('.comment-input');
263+
264+
let expected = { comment: 'You are not a wizard!' };
265+
assert.deepEqual(actual, expected, 'submitted value is passed to external action');
272266
});
273267
});
274268
```
@@ -522,11 +516,11 @@ module('Integration | Component | delayed-typeahead', function(hooks) {
522516
];
523517

524518
test('should render results after typing a term', async function(assert) {
525-
assert.expect(2);
526-
527519
this.set('results', []);
528-
this.set('fetchResults', (value) => {
529-
assert.equal(value, 'test', 'fetch closure action called with search value');
520+
521+
let value;
522+
this.set('fetchResults', (data) => {
523+
value = data;
530524
this.set('results', stubResults);
531525
});
532526

@@ -535,6 +529,7 @@ module('Integration | Component | delayed-typeahead', function(hooks) {
535529
this.element.querySelector('input').dispatchEvent(new Event('keyup'));
536530

537531
await settled();
532+
assert.equal(value, 'test', 'fetch closure action called with search value');
538533

539534
assert.equal(this.element.querySelectorAll('.result').length, 2, 'two results rendered');
540535
});

guides/v2.10.0/tutorial/autocomplete-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export default function() {
230230
city: 'Seattle',
231231
type: 'Condo',
232232
bedrooms: 1,
233-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
233+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
234234
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
235235
}
236236
}, {

guides/v2.10.0/tutorial/installing-addons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function() {
6666
city: 'Seattle',
6767
type: 'Condo',
6868
bedrooms: 1,
69-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
69+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg'
7070
}
7171
}, {
7272
type: 'rentals',

guides/v2.10.0/tutorial/model-hook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let rentals = [{
2929
city: 'Seattle',
3030
type: 'Condo',
3131
bedrooms: 1,
32-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
32+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg'
3333
}, {
3434
id: 'downtown-charm',
3535
title: 'Downtown Charm',

guides/v2.10.0/tutorial/subroutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export default function() {
182182
city: "Seattle",
183183
type: "Condo",
184184
bedrooms: 1,
185-
image: "https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg",
185+
image: "https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg",
186186
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
187187
}
188188
},

guides/v2.11.0/tutorial/autocomplete-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export default function() {
230230
city: 'Seattle',
231231
type: 'Condo',
232232
bedrooms: 1,
233-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
233+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
234234
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
235235
}
236236
}, {

guides/v2.11.0/tutorial/ember-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default Ember.Route.extend({
8282
city: 'Seattle',
8383
type: 'Condo',
8484
bedrooms: 1,
85-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
85+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
8686
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
8787
}, {
8888
id: 'downtown-charm',

guides/v2.11.0/tutorial/installing-addons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function() {
6666
city: 'Seattle',
6767
type: 'Condo',
6868
bedrooms: 1,
69-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
69+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg'
7070
}
7171
}, {
7272
type: 'rentals',

guides/v2.11.0/tutorial/model-hook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default Ember.Route.extend({
3838
city: 'Seattle',
3939
type: 'Condo',
4040
bedrooms: 1,
41-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
41+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
4242
description: 'A commuters dream. This rental is within walking distance of 2 bus stops and the Metro.'
4343

4444
}, {

guides/v2.11.0/tutorial/subroutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default function() {
183183
city: "Seattle",
184184
type: "Condo",
185185
bedrooms: 1,
186-
image: "https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg",
186+
image: "https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg",
187187
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
188188
}
189189
},

guides/v2.12.0/tutorial/autocomplete-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export default function() {
163163
city: 'Seattle',
164164
type: 'Condo',
165165
bedrooms: 1,
166-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
166+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
167167
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
168168
}
169169
}, {

guides/v2.12.0/tutorial/ember-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default Ember.Route.extend({
8282
city: 'Seattle',
8383
type: 'Condo',
8484
bedrooms: 1,
85-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
85+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
8686
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
8787
}, {
8888
id: 'downtown-charm',

guides/v2.12.0/tutorial/installing-addons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function() {
7070
city: 'Seattle',
7171
type: 'Condo',
7272
bedrooms: 1,
73-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
73+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg'
7474
}
7575
}, {
7676
type: 'rentals',

guides/v2.12.0/tutorial/model-hook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default Ember.Route.extend({
3838
city: 'Seattle',
3939
type: 'Condo',
4040
bedrooms: 1,
41-
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg',
41+
image: 'https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg',
4242
description: 'A commuters dream. This rental is within walking distance of 2 bus stops and the Metro.'
4343

4444
}, {

guides/v2.12.0/tutorial/subroutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default function() {
183183
city: "Seattle",
184184
type: "Condo",
185185
bedrooms: 1,
186-
image: "https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg",
186+
image: "https://upload.wikimedia.org/wikipedia/commons/2/20/Seattle_-_Barnes_and_Bell_Buildings.jpg",
187187
description: "A commuters dream. This rental is within walking distance of 2 bus stops and the Metro."
188188
}
189189
},

0 commit comments

Comments
 (0)