Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4952e4c

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: Frontend Encore document passing data via serialize twig filter
2 parents1aa135c +627668f commit4952e4c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎frontend/encore/server-data.rst‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ them later in JavaScript. For example:
88

99
..code-block::html+twig
1010

11-
<div class="js-user-rating" data-is-authenticated="{{ app.user ? 'true' : 'false' }}">
11+
<div class="js-user-rating"
12+
data-is-authenticated="{{ app.user ? 'true' : 'false' }}"
13+
data-user="{{ app.user|serialize(format = 'json') }}"
14+
>
1215
<!-- ... -->
1316
</div>
1417

@@ -19,6 +22,7 @@ Fetch this in #"diff-b57b959d767cb5a19a2579935ea380754ec0d1f16f32fa5939432421c1f210d0-19-22-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">19
22
document.addEventListener('DOMContentLoaded',function() {
2023
var userRating=document.querySelector('.js-user-rating');
2124
var isAuthenticated=userRating.dataset.isAuthenticated;
25+
var user=JSON.parse(userRating.dataset.user);
2226
2327
// or with jQuery
2428
//var isAuthenticated = $('.js-user-rating').data('isAuthenticated');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp