[Frontend] Correct escape type for HTML attribute example

This commit is contained in:
Chris Brown
2025-11-19 11:13:59 +00:00
committed by GitHub
parent ceab14bd7a
commit b82557dc3a

View File

@@ -38,13 +38,13 @@ Fetch this in JavaScript:
const user = JSON.parse(userRating.dataset.user);
There is no size limit for the value of the ``data-*`` attributes, so you can
store any content. In Twig, use the ``html_attr`` escaping strategy to avoid messing
store any content. In Twig, use the ``html`` escaping strategy to avoid messing
with HTML attributes. For example, if your ``User`` object has some ``getProfileData()``
method that returns an array, you could do the following:
.. code-block:: html+twig
<div data-user-profile="{{ app.user ? app.user.profileData|json_encode|e('html_attr') }}">
<div data-user-profile="{{ app.user ? app.user.profileData|json_encode|e('html') }}">
<!-- ... -->
</div>