Skip to content

Commit

Permalink
Apply modifications for 4.11 guides (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueCutOfficial committed Mar 31, 2023
1 parent f1015da commit efa9ba7
Show file tree
Hide file tree
Showing 34 changed files with 276 additions and 141 deletions.
2 changes: 1 addition & 1 deletion guides/release/code-editors/index.md
Expand Up @@ -100,7 +100,7 @@ Atom package to use the Ember Language Server.
Atom autocomplete and snippets for Ember.js.

[atom-ember-snippets](https://github.com/mattmcmanus/atom-ember-snippets) -
Ember.js ES6, Ember Data & Handlebars snippets for Atom editor.
Ember.js ES6, EmberData & Handlebars snippets for Atom editor.

[language-ember-htmlbars](https://atom.io/packages/language-ember-htmlbars) -
Add Ember template syntax highlighting and indentation to Atom
Expand Down
15 changes: 10 additions & 5 deletions guides/release/components/index.md
Expand Up @@ -148,24 +148,29 @@ body {

form {
display: grid;
grid-column: span 2;
grid-template-columns: 1fr 6em;
grid-template-rows: repeat(2, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
grid-column: span 2;
}

form > label {
grid-area: 1 / 1 / 2 / 2;
}

form > input {
padding: 0.5em;
border-top-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
border: 1px solid #cccccc;
border-right: none;
font-size: 1em;
grid-area: 2 / 1 / 3 / 2;
}

form > button {
border-top-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
border: 1px solid #cccccc;
font-size: 1em;
grid-area: 2 / 2 / 3 / 3;
}
```

Expand Down
2 changes: 1 addition & 1 deletion guides/release/contributing/repositories.md
Expand Up @@ -9,7 +9,7 @@ Ember is made up of several libraries. If you wish to add a feature or fix a bug

* [https://github.com/ember-cli/ember-cli](https://github.com/ember-cli/ember-cli)

**Ember Data** - A data persistence library for Ember.
**EmberData** - A data persistence library for Ember.

* [https://github.com/emberjs/data](https://github.com/emberjs/data)

Expand Down
2 changes: 1 addition & 1 deletion guides/release/ember-inspector/data.md
Expand Up @@ -30,4 +30,4 @@ You can also filter records by entering a query in the search box.
### Building a Data Custom Adapter

You can use your own data persistence library with the Inspector. Build a [data adapter](https://github.com/emberjs/ember.js/blob/3ac2fdb0b7373cbe9f3100bdb9035dd87a849f64/packages/ember-extension-support/lib/data_adapter.js), and you can inspect your models
using the Data tab. Use [Ember Data's data adapter](https://github.com/emberjs/data/blob/d7988679590bff63f4d92c4b5ecab173bd624ebb/packages/ember-data/lib/system/debug/debug_adapter.js) as an example for how to build your data adapter and [DataAdapter](https://api.emberjs.com/ember/release/classes/DataAdapter) documentation.
using the Data tab. Use [EmberData's data adapter](https://github.com/emberjs/data/blob/d7988679590bff63f4d92c4b5ecab173bd624ebb/packages/ember-data/lib/system/debug/debug_adapter.js) as an example for how to build your data adapter and [DataAdapter](https://api.emberjs.com/ember/release/classes/DataAdapter) documentation.
4 changes: 2 additions & 2 deletions guides/release/ember-inspector/object-inspector.md
Expand Up @@ -78,7 +78,7 @@ left-facing arrow at the top left.
### Custom Property Grouping

Some properties are not only grouped by inheritance, but also
by framework level semantics. For example, if you inspect an Ember Data
by framework level semantics. For example, if you inspect an EmberData
model, you can see `Attributes`, `Belongs To`, `Has Many`, and `Flags`
groups.

Expand All @@ -87,5 +87,5 @@ width="450">

Library authors can customize how any object will display in the Inspector.
By defining a `_debugInfo` method, an object can tell the Inspector how it should be rendered.
For an example on how to customize an object's properties, see [Ember Data's
For an example on how to customize an object's properties, see [EmberData's
customization](https://github.com/emberjs/data/blob/f1be2af71d7402d034bc034d9502733647cad295/packages/ember-data/lib/system/debug/debug_info.js).
2 changes: 1 addition & 1 deletion guides/release/getting-started/anatomy-of-an-ember-app.md
Expand Up @@ -28,7 +28,7 @@ Par exemple, notre application de gestion de locations devrait pouvoir enregistr

En général, on persiste les informations d'un modèle en les envoyant à un serveur web, bien qu'en réalité il soit possible de les sauvegarder n'importe où ailleurs, comme par exemple dans le "Local Storage" du navigateur.

Par défaut, une nouvelle app Ember inclut [Ember Data](../../models/), une librairie de gestion de données distincte du framework, mais très conventionnelle. Ember Data s'intègre avec Ember et fournit une strate solide pour gérer les modèles.
Par défaut, une nouvelle app Ember inclut [EmberData](../../models/), une librairie de gestion de données distincte du framework, mais très conventionnelle. EmberData s'intègre avec Ember et fournit une strate solide pour gérer les modèles.

Vous pouvez cependant manipuler vos modèles à l'aide de n'importe quelle autre librairie de gestion de données, comme [Redux](https://github.com/ember-redux/ember-redux) ou
[Apollo](https://github.com/ember-graphql/ember-apollo-client), ou même créer votre propre système en vous appuyant sur les outils fournis par Ember pour gérer les états, comme [autotracking](../../components/component-state-and-actions/). Nous en apprendrons plus sur ces outils dans d'autres parties du guide.
Expand Down
2 changes: 1 addition & 1 deletion guides/release/getting-started/index.md
Expand Up @@ -11,7 +11,7 @@ Some of these features that you'll learn about in the guides are:
* [Components](../components/) - The fundamental construct used in Ember applications, used to create reusable UI elements and define the layout and the functionality of the app.
* [Routing](../routing/) - A central part of an Ember application. Enables developers to drive the application state from the URL.
* [Services](../services/) - The way to store long-term state in your application and pass it around.
* [Ember Data](../models/) - Ember Data provides a consistent way to communicate with external APIs and manage application state
* [EmberData](../models/) - EmberData provides a consistent way to communicate with external APIs and manage application state
* [Ember Inspector](../ember-inspector/) - A browser extension, or bookmarklet, to inspect your application live. It's also useful for spotting Ember applications in the wild, try to install it and open up the [NASA website](https://www.nasa.gov/)!

## Organization
Expand Down
2 changes: 1 addition & 1 deletion guides/release/in-depth-topics/making-api-requests.md
Expand Up @@ -8,7 +8,7 @@ Follow the links within it to see examples and learn more.

Some common tools for making [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) (create, read, update, delete) requests in Ember include:

- [Ember Data](../../models/) is the official data persistence library for Ember. It has a powerful set of tools
- [EmberData](../../models/) is the official data persistence library for Ember. It has a powerful set of tools
for formatting requests, normalizing responses, and efficiently
managing a local cache of data.
It is included by default in new Ember apps.
Expand Down
2 changes: 1 addition & 1 deletion guides/release/in-depth-topics/native-classes-in-depth.md
Expand Up @@ -721,7 +721,7 @@ normally would.

One common example is when overriding the
[`normalizeResponse()`](https://api.emberjs.com/ember-data/release/classes/JSONAPISerializer/methods/normalizeResponse?anchor=normalizeResponse)
hook in one of Ember Data's serializers.
hook in one of EmberData's serializers.

A handy shortcut for this is to use a "spread operator", like `...arguments`:

Expand Down
65 changes: 65 additions & 0 deletions guides/release/in-depth-topics/patterns-for-components.md
Expand Up @@ -169,6 +169,28 @@ or
{{/each}}
```
Or, for example the layout for a SuperForm component might be implemented as:
```handlebars {data-filename=app/components/super-form.hbs}
<form>
{{yield (hash
Input=(component "super-input" form=this model=this.model)
Textarea=(component "super-textarea" form=this model=this.model)
Submit=(component "super-submit" form=this model=this.model)
)}}
</form>
```
And be used as:
```handlebars {data-filename=app/templates/index.hbs}
<SuperForm @model={{this.post}} as |f|>
<f.Input @name="title" />
<f.Textarea @name="body" />
<f.Submit />
</SuperForm>
```
When the parameter passed to `{{component}}` evaluates to `null` or `undefined`,
the helper renders nothing. When the parameter changes, the currently rendered
component is destroyed and the new component is created and brought in.
Expand All @@ -177,6 +199,49 @@ Picking different components to render in response to the data allows you to
have a different template and behavior for each case. The `{{component}}` helper
is a powerful tool for improving code modularity.
### Contextual helpers & modifiers
We can even use helpers and modifiers in the same way. Let's extend the SuperForm component:
```handlebars {data-filename=app/components/super-form.hbs}
<form>
{{yield (hash
Input=(component "super-input" form=this model=this.model)
Textarea=(component "super-textarea" form=this model=this.model)
Submit=(component "super-submit" form=this model=this.model)
is-valid=(helper "super-is-valid" form=this model=this.model)
error-for=(helper "super-error-for" form=this model=this.model)
auto-resize=(modifier "super-auto-resize")
)}}
</form>
```
And be used as:
```handlebars {data-filename=app/templates/index.hbs}
<SuperForm @model={{this.post}} as |f|>
{{! Invoke a contextual component }}
<f.Input @name="title" />
{{! Invoke contextual helpers }}
{{#unless (f.is-valid "title")}}
<div class="error">This field {{f.error-for "title"}}</div>
{{/unless}}
{{! Invoke a contextual modifier on a contextual component invocation }}
<f.Textarea @name="body" {{f.auto-resize maxHeight="500"}} />
<f.Submit />
</SuperForm>
```
These APIs open the doors for the creation of new, more powerful UI abstractions.
## Learn More
To keep this guide concise, we built a separate site for [component patterns in Ember](https://emberjs-1.gitbook.io/ember-component-patterns/).
Expand Down
87 changes: 87 additions & 0 deletions guides/release/in-depth-topics/rendering-values.md
@@ -0,0 +1,87 @@
In Ember, rendering occurs via syntax, rather than by value -- so _anything_ can be a modifier, helper, or component.

## Modifiers

For Modifiers, there is a specific syntax that only modifiers may reside in
```hbs
<div {{someModifier}}>
```
or via property on some object
```hbs
<div {{this.property.someModifier}}>
```
or via an argument passed to a component
```hbs
<div {{@someModifier}}>
```

Modifiers can be curried with the `modifier` helper:
```hbs
{{! In a component called "Example" }}
{{yield (modifier someModifier "arguments" "here")}}
{{! Usage: }}
<Example as |theModifier|>
<div {{theModifier}}>
</Example>
```


## Helpers

For Helpers, there is a specific syntax that only helpers may reside in
```hbs
{{ (theHelper) }}
```
or nested in a sub-expression
```hbs
{{yield (hash key=(theHelper) key2=(theHelper with args)) }}
```
or via property on some object
```hbs
{{ (this.property.theHelper) }}
```
or via an argument passed to a component
```hbs
{{ (@theHelper) }}
```

Helpers can be curried with the `helper` helper:
```hbs
{{! In a component called "Example" }}
{{yield (helper someHelper "arguments" "here")}}
{{! Usage: }}
<Example as |theHelper|>
{{ (theHelper) }}
</Example>
```

## Components

For Components, there is a specific syntax that only components may reside in
```hbs
<AComponent />
```
or via a property on some object
```hbs
<this.someComponent />
```
or via an argument passed to a component
```hbs
<@someComponent />
```

Components can be curried with the `component` helper:
```hbs
{{!
In a component called "Example".
Note that components may only receive named arguments
}}
{{yield (component someComponent foo="arguments" bar="here")}}
{{! Usage: }}
<Example as |theComponent|>
<theComponent />
</Example>
```
2 changes: 1 addition & 1 deletion guides/release/index.md
Expand Up @@ -13,7 +13,7 @@ Avec la pléthore de bibliothèques disponibles pour le développement front-end
<div class="shape shape--dark"></div>
<div class="shape shape--accent"></div>
<div class="shape shape--light"></div>
<a href="./models/">Ember Data</a>
<a href="./models/">EmberData</a>
</li>
<li class="list-item-card">
<div class="shape shape--dark"></div>
Expand Down
14 changes: 7 additions & 7 deletions guides/release/models/creating-updating-and-deleting-records.md
Expand Up @@ -5,17 +5,17 @@ You can create records by calling the
method on the store.

```javascript
store.createRecord('post', {
this.store.createRecord('post', {
title: 'Rails is Omakase',
body: 'Lorem ipsum'
});
```

The store object is available in controllers and routes using `this.store`.
To make `store` available, you can [inject the `store` service](../#toc_injecting-the-store).

## Updating Records

Making changes to Ember Data records is as simple as setting the attribute you
Making changes to EmberData records is as simple as setting the attribute you
want to change:

```javascript
Expand All @@ -27,15 +27,15 @@ this.store.findRecord('post', 1).then(function(post) {

## Persisting Records

Records in Ember Data are persisted on a per-instance basis.
Records in EmberData are persisted on a per-instance basis.
Call [`save()`](https://api.emberjs.com/ember-data/release/classes/Model/methods/save?anchor=save)
on any instance of `Model` and it will make a network request.

Ember Data takes care of tracking the state of each record for
you. This allows Ember Data to treat newly created records differently
EmberData takes care of tracking the state of each record for
you. This allows EmberData to treat newly created records differently
from existing records when saving.

By default, Ember Data will `POST` newly created records to their type URL.
By default, EmberData will `POST` newly created records to their type URL.

```javascript
let post = store.createRecord('post', {
Expand Down

0 comments on commit efa9ba7

Please sign in to comment.