forked from sveltejs/svelte.dev
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69e732f
commit f595587
Showing
6 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
apps/svelte.dev/content/tutorial/01-svelte/04-logic/01-if-blocks/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
--- | ||
title: If blocks | ||
title: Blocs If | ||
--- | ||
|
||
HTML doesn't have a way of expressing _logic_, like conditionals and loops. Svelte does. | ||
Le HTML ne permet pas d'exprimer de la _logique_, comme des conditions ou des boucles. Svelte si. | ||
|
||
To conditionally render some markup, we wrap it in an `if` block. Let's add some text that appears when `count` is greater than `10`: | ||
Pour afficher du markup de manière conditionnelle, plaçons-le dans un bloc `if`. Ajoutons-lui un | ||
peut de texte à afficher lorsque `count` est plus grand que `10` : | ||
|
||
```svelte | ||
/// file: App.svelte | ||
<button onclick={increment}> | ||
Clicked {count} | ||
{count === 1 ? 'time' : 'times'} | ||
Il y a eu {count} | ||
{count === 1 ? 'clic' : 'clics'} | ||
</button> | ||
+++{#if count > 10} | ||
<p>{count} is greater than 10</p> | ||
<p>{count} est plus grand que 10</p> | ||
{/if}+++ | ||
``` | ||
|
||
Try it — update the component, and click on the button a few times. | ||
Essayez — mettez à jour le composant, et cliquez plusieurs fois sur le bouton. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
apps/svelte.dev/content/tutorial/01-svelte/04-logic/02-else-blocks/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
--- | ||
title: Else blocks | ||
title: Blocs Else | ||
--- | ||
|
||
Just like in JavaScript, an `if` block can have an `else` block: | ||
De la même manière qu'en JavaScript, un bloc `if` peut avoir un bloc `else` : | ||
|
||
```svelte | ||
/// file: App.svelte | ||
{#if count > 10} | ||
<p>{count} is greater than 10</p> | ||
<p>{count} est plus grand que 10</p> | ||
+++{:else} | ||
<p>{count} is between 0 and 10</p>+++ | ||
<p>{count} est entre 0 et 10</p>+++ | ||
{/if} | ||
``` | ||
|
||
`{#...}` opens a block. `{/...}` closes a block. `{:...}` _continues_ a block. Congratulations — you've already learned almost all the syntax Svelte adds to HTML. | ||
`{#...}` ouvre un bloc. `{/...}` ferme un bloc. `{:...}` _continue_ un bloc. Félicitations — vous | ||
avez déjà appris presque toute la syntaxe que Svelte rajoute au HTML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Logic | ||
title: Logique | ||
scope: { 'prefix': '/src/lib/', 'name': 'src' } | ||
focus: /src/lib/App.svelte | ||
--- |