Skip to content

Commit 523d632

Browse files
authored
Merge branch 'octane' into kategengler-patch-1
2 parents ab150d3 + 3063d47 commit 523d632

File tree

12 files changed

+173
-224
lines changed

12 files changed

+173
-224
lines changed

config/environment.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ module.exports = function(environment) {
5656
}
5757
},
5858
],
59-
survey: {
60-
link: 'https://emberjs.com/ember-community-survey-2019/',
61-
title: '2019 Ember Community Survey'
59+
infoBanner: {
60+
content: `Thanks for taking the Octane preview for a test drive! Visit
61+
<a href="https://emberjs.com" target="_blank" rel="noopener">emberjs.com/octane</a>
62+
for more info and ways you can help out.
63+
These preview guides URLs are subject to change, so point your bookmarks at that landing page.
64+
If you are looking for the latest stable release of Ember, please instead visit
65+
<a href="https://guides.emberjs.com" target="_blank" rel="noopener">guides.emberjs.com</a>.`
6266
},
6367
};
6468

guides/release/pages.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
- title: "What Is Ember"
2-
url: "what-is-ember"
1+
- title: "Introduction"
2+
url: 'index'
3+
pages:
4+
- title: "What Is Ember"
5+
url: ""
36
- title: "Getting Started"
47
url: 'getting-started'
58
pages:

guides/release/state-management/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ the application does. However, they are _more_ controlled than globals like
203203
`window` because:
204204

205205
1. They can _only_ be injected into other Ember objects, not custom classes.
206-
2. They can _only_ be used in places where they are injected. Random functions
207-
can't access a service for a one of change.
206+
2. They can _only_ be used in places where they are injected.
208207

209208
This means that you can narrow down changes to state in services to a number of
210209
locations, and generally control the data flow more easily.

guides/release/templates/actions.md

Lines changed: 53 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,70 @@ the context of the template:
88

99
```javascript {data-filename=app/components/post/component.js}
1010
import Component from '@glimmer/component';
11+
import { tracked } from '@glimmer/tracking';
1112
import { action } from '@ember/object';
1213

1314
export default class Post extends Component {
15+
@tracked isShowingBody;
16+
1417
@action
1518
toggleBody() {
16-
this.toggleProperty('isShowingBody');
19+
this.isShowingBody = !this.isShowingBody;
1720
}
1821
}
1922
```
2023

21-
You can then add this action directly to an [_event handler
22-
property_](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers)
23-
on an element, like `onclick` or `onmouseenter`:
24+
You can then add this action to an element using the
25+
[`{{action}}`](https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/action?anchor=action)
26+
helper:
2427

2528
```handlebars {data-filename=app/components/post/template.hbs}
2629
<h3>
27-
<button onclick={{this.toggleBody}}>{{this.title}}</button>
30+
<button {{action this.toggleBody}}>{{@title}}</button>
2831
</h3>
2932
3033
{{#if this.isShowingBody}}
31-
<p>{{this.body}}</p>
34+
<p>{{@body}}</p>
3235
{{/if}}
3336
```
3437

35-
This assigns the action to the standard browser event handler for that function.
36-
It'll receive the event as its first parameter, and you can handle it like any
37-
standard JavaScript event:
38-
39-
```javascript {data-filename=app/components/post/component.js}
40-
import Component from '@glimmer/component';
41-
import { action } from '@ember/object';
42-
43-
export default class Post extends Component {
44-
@action
45-
toggleBody(event) {
46-
event.preventDefault();
47-
event.stopPropagation();
48-
this.toggleProperty('isShowingBody');
49-
}
50-
}
51-
```
52-
38+
The `{{action}}` helper calls your action function when the element is
39+
clicked.
5340
You will learn about more advanced usages in the Component's [Actions and
5441
Events](../../components/actions-and-events/) guide, but you should familiarize
55-
yourself with the following basics first.
42+
yourself with the basics on this page first.
43+
44+
Templates rendered for your application's routes are backed by controllers, so
45+
you may also see actions defined on a controller using the same `@action`
46+
decorator.
47+
48+
<div class="cta">
49+
<div class="cta-note">
50+
<div class="cta-note-body">
51+
<div class="cta-note-heading">Zoey says...</div>
52+
<div class="cta-note-message">
53+
If this doesn't seem familiar you might be looking for documentation
54+
about Ember components and controller that use the older <code>.extend({</code> syntax.
55+
In those files you define actions in an object on the class then reference
56+
the action name with a string in the template.
57+
For more examples of that syntax see <a href="https://guides.emberjs.com/v3.6.0/templates/actions/">previous version of this Guide entry</a>.
58+
</div>
59+
</div>
60+
<img src="/images/mascots/zoey.png" role="presentation" alt="Ember Mascot">
61+
</div>
62+
</div>
5663

5764
## Action Parameters
5865

59-
You can optionally pass arguments to the action with the
60-
[`{{action}}`](https://www.emberjs.com/api/ember/release/classes/Ember.Templates.helpers/methods/action?anchor=action)
66+
You can optionally pass arguments to the action
6167
helper. For example, if the `post` argument was passed:
6268

6369
```handlebars {data-filename=app/components/post/template.hbs}
6470
<p>
65-
<button onclick={{action this.select this.post}}>
71+
<button {{action this.select @post}}>
6672
6773
</button>
68-
{{this.post.title}}
74+
{{this.selectedPost.title}}
6975
</p>
7076
```
7177

@@ -87,71 +93,37 @@ export default class Post extends Component {
8793
}
8894
```
8995

90-
If you pass arguments like this, the event will be the _last_ argument that is
91-
passed to the handler:
96+
## Attaching Actions to Other Events
97+
98+
Actions don't need to be triggered on click, in fact they can be attached
99+
to any event Ember is already listening to. For example this form will
100+
call the `updateText` action when submitted, but prevent the default
101+
form submission logic in the browser from running:
102+
103+
```handlebars {data-filename=app/components/post/template.hbs}
104+
<form {{action this.createPost on="submit" preventDefault=true}}>
105+
Post title: <Input @value={{this.title}} />
106+
</form>
107+
```
92108

93109
```javascript {data-filename=app/components/post/component.js}
94110
import Component from '@glimmer/component';
95111
import { tracked } from '@glimmer/tracking';
96112
import { action } from '@ember/object';
97113

98114
export default class Post extends Component {
99-
@tracked selectedPost;
115+
@tracked title;
100116

101117
@action
102-
select(post, event) {
103-
event.preventDefault();
104-
event.stopPropagation();
105-
this.selectedPost = post;
106-
}
107-
}
108-
```
109-
110-
## Modifying the action's first parameter
111-
112-
If a `value` option for the `{{action}}` helper is specified, its value will be
113-
considered a property path that will be read off of the first parameter of the
114-
action. This comes very handy with event listeners and enables to work with
115-
one-way bindings.
116-
117-
```handlebars
118-
<label>What's your favorite band?</label>
119-
<input
120-
type="text"
121-
value={{this.favoriteBand}}
122-
onblur={{this.bandDidChange}}
123-
/>
124-
```
125-
126-
Let's assume we have an action handler that prints its first parameter:
127-
128-
```javascript
129-
actions: {
130-
bandDidChange(newValue) {
131-
console.log(newValue);
118+
createPost() {
119+
// Do something with `this.title`
132120
}
133121
}
134122
```
135123

136-
By default, the action handler receives the first parameter of the event
137-
listener, the event object the browser passes to the handler, so `bandDidChange`
138-
prints `Event {}`.
139-
140-
Using the `value` option modifies that behavior by extracting that property from
141-
the event object:
142-
143-
```handlebars
144-
<label>What's your favorite band?</label>
145-
<input
146-
type="text"
147-
value={{this.favoriteBand}}
148-
onblur={{action this.bandDidChange value="target.value"}}
149-
/>
150-
```
151-
152-
The `newValue` parameter thus becomes the `target.value` property of the event
153-
object, which is the value of the input field the user typed. (e.g 'Foo
154-
Fighters')
124+
Read about which events Ember is already listening to in
125+
[Handling Events: Event
126+
Names](../../components/handling-events/#toc_event-names).
155127

156128
## Attaching Actions to Non-Clickable Elements
157129

guides/release/templates/binding-element-attributes.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,41 @@ If `isAdministrator` is `false`, Handlebars will produce the following:
3838
<input type="checkbox">
3939
```
4040

41-
### Adding Other Attributes (Including Data Attributes)
41+
### Adding Attributes to Component Invocations
4242

43-
By default, components only accept a limited number of HTML attributes.
44-
This means that some uncommon but perfectly valid attributes, such as `lang` or
45-
custom `data-*` attributes must be specifically enabled. For example, this template:
43+
Components in Ember can also accept attributes to be placed on an element
44+
which they render. A common use for this might be `lang` or `data-*`
45+
attributes. For example, this template passes those two attributes to
46+
a link component:
4647

4748
```handlebars
48-
{{#link-to "photos" data-toggle="dropdown" lang="es"}}Fotos{{/link-to}}
49+
<LinkTo @route="photos" data-toggle="dropdown" lang="es">
50+
Fotos
51+
</LinkTo>
4952
```
5053

51-
Will render the following HTML:
54+
Which will render render the following HTML:
5255

5356
```html
54-
<a id="ember239" class="ember-view" href="#/photos">Fotos</a>
57+
<a href="/photos" data-toggle="dropdown" lang="es" id="ember239" class="ember-view">
58+
Fotos
59+
</a>
5560
```
5661

57-
To enable support for these attributes, an attribute binding must be
58-
added for each specific attribute on the component.
59-
To do this, you can extend the appropriate components
60-
in your application. For example, for `link-to` you would create your own version
61-
of this component by extending
62-
[`Ember.LinkComponent`](https://www.emberjs.com/api/ember/release/classes/LinkComponent)
63-
64-
```javascript {data-filename="app/components/link-to/component.js"}
65-
import LinkComponent from '@ember/routing/link-component';
66-
67-
export default LinkComponent.extend({
68-
attributeBindings: ['data-toggle', 'lang']
69-
});
70-
```
71-
72-
Now the same template above renders the following HTML:
73-
74-
```html
75-
<a id="ember239" class="ember-view" href="#/photos" data-toggle="dropdown" lang="es">Fotos</a>
76-
```
62+
Components can control which of their elements receive attributes.
63+
[Read more about how to customize a component's element](../../components/customizing-a-components-element/).
64+
65+
<div class="cta">
66+
<div class="cta-note">
67+
<div class="cta-note-body">
68+
<div class="cta-note-heading">Zoey says...</div>
69+
<div class="cta-note-message">
70+
This API uses a recent and new feature in Ember: Angle bracket invocation
71+
syntax of an Ember component. If this doesn't look familiar you may be
72+
working with classic component invocation syntax (for example <code>{{link-to}}</code>).
73+
For more examples of ways to use components in a template, see the <a href="../../reference/syntax-conversion-guide">Syntax Conversion Guide</a> or the <a href="https://guides.emberjs.com/v3.6.0/templates/binding-element-attributes/">previous version of this Guide entry</a>.
74+
</div>
75+
</div>
76+
<img src="/images/mascots/zoey.png" role="presentation" alt="Ember Mascot">
77+
</div>
78+
</div>

guides/release/templates/built-in-helpers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
In the last section you learned how to write a helper. A helper is usually a
1+
A helper is usually a
22
simple function that can be used in any template. Ember comes with a few helpers
33
that can make developing your templates a bit easier. These helpers can allow
44
you to be more dynamic in passing data to another helper or component.
@@ -168,10 +168,10 @@ when the `debugger;` breakpoint is hit, you can attempt to retrieve this value:
168168
{{/each}}
169169
```
170170

171-
You'll be able to get values from the current item:
171+
You'll be able to get the value of the current item:
172172

173173
```javascript
174-
> get('this.item.name')
174+
> get('item.name')
175175
```
176176

177177
You can also access the context of the view to make sure it is the object that

guides/release/templates/displaying-the-keys-in-an-object.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ If you need to display all of the keys or values of a JavaScript object in your
22
you can use the [`{{#each-in}}`](https://www.emberjs.com/api/ember/release/classes/Ember.Templates.helpers/methods/if?anchor=each-in) helper:
33

44
```javascript {data-filename=/app/components/store-categories.js}
5-
import Component from '@ember/component';
5+
import Component from '@glimmer/component';
66

7-
export default Component.extend({
8-
willRender() {
9-
// Set the "categories" property to a JavaScript object
10-
// with the category name as the key and the value a list
11-
// of products.
12-
this.set('categories', {
13-
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'],
14-
'Ryes': ['WhistlePig', 'High West']
15-
});
16-
}
7+
export default class extends Component {
8+
// Set the "categories" property to a JavaScript object
9+
// with the category name as the key and the value a list
10+
// of products.
11+
categories = {
12+
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'],
13+
'Ryes': ['WhistlePig', 'High West']
14+
};
1715
});
1816
```
1917

guides/release/templates/handlebars-basics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ about it! -->
129129
<!-- One way to use a component within a template -->
130130
<MyComponent />
131131
132-
{{! Example of a comment that will be invisible, even
133-
if it contains things in {{curlyBraces}} }}
134-
132+
{{! A Handlebars comment. These comments, unlike, HTML
133+
comments, are not rendered in the DOM. They are
134+
removed when the template is compiled. }}
135135
```
136136

137137
Component example:
@@ -150,7 +150,7 @@ A method named `plantATree` is called when the button is
150150
clicked. `plantATree` comes from the JavaScript file
151151
associated with the template, like a Component or
152152
Controller -->
153-
<button onclick={{action 'plantATree'}}>
153+
<button {{action 'plantATree'}}>
154154
More trees!
155155
<button>
156156

0 commit comments

Comments
 (0)