Skip to content

Commit

Permalink
fr: tutorial 01/04/01-02
Browse files Browse the repository at this point in the history
  • Loading branch information
bleucitron committed Jan 13, 2025
1 parent 69e732f commit f595587
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</script>

<button onclick={increment}>
Clicked {count}
{count === 1 ? 'time' : 'times'}
Il y a eu {count}
{count === 1 ? 'clic' : 'clics'}
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</script>

<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}
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.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</script>

<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>
{:else}
<p>{count} is between 0 and 10</p>
<p>{count} est entre 0 et 10</p>
{/if}
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.
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
---

0 comments on commit f595587

Please sign in to comment.