Skip to content

Commit

Permalink
Render store data in the DOM using the @JSON blade directive
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMuller committed Jan 8, 2024
1 parent 95cfdd1 commit ba1e64b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to `laravel-js-store` will be documented in this file

## 3.1.0 - 2024-08-01
- Render store data in the DOM using the @json blade directive

## 3.0.0 - 2023-03-01
- Add support for Laravel 10
- Add support for PHP 8.2
Expand Down
2 changes: 1 addition & 1 deletion resources/views/script.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script
id="laravel-js-store-{{ $rand }}"
data-store="{{ json_encode(frontend_store()->data()) }}"
data-store='@json(frontend_store()->data(), JSON_THROW_ON_ERROR | JSON_HEX_APOS | JSON_HEX_QUOT)'
>
var el = document.getElementById('laravel-js-store-{{ $rand }}')
window.{{ config('js-store.window-element') }} = JSON.parse(el.dataset.store)
Expand Down

0 comments on commit ba1e64b

Please sign in to comment.