Commit fcb6dce
committed
minor #21581 Correct escape type for HTML attribute example (ChrisDBrown)
This PR was merged into the 6.4 branch.
Discussion
----------
Correct escape type for HTML attribute example
From the [Twig documentation](https://twig.symfony.com/doc/3.x/filters/escape.html) the different html escapes are (emphasis mine):
- `html`: escapes a string for the HTML body context, or for **HTML attributes values inside quotes**.
- `html_attr`: escapes a string when used as an HTML attribute name, and also when used as the value of an **HTML attribute without quotes** (e.g. `data-attribute={{ some_value }}`).
The example code here is inside quotes:
```
<div data-user-profile="{{ app.user ? app.user.profileData|json_encode|e('html') }}">
<!-- ... -->
</div>
```
so it seems better to recommend `html` as the escape strategy. It'd perhaps be better still to highlight this difference in the Symfony docs?
Commits
-------
b82557d [Frontend] Correct escape type for HTML attribute example1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
0 commit comments