File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ Subscribing to updates in JavaScript from a Twig template is straightforward:
251251 // Will be called every time an update is published by the server
252252 console.log(JSON.parse(event.data));
253253 }
254- <script>
254+ </ script>
255255
256256 The ``mercure() `` Twig function will generate the URL of the Mercure hub
257257according to the configuration. The URL will include the ``topic `` query
@@ -260,13 +260,15 @@ parameters corresponding to the topics passed as first argument.
260260If you want to access to this URL from an external JavaScript file, generate the
261261URL in a dedicated HTML element:
262262
263- .. code :: twig
263+ .. code-block :: twig
264264
265- <script type="application/json" id="mercure-url">{{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}</script>
265+ <script type="application/json" id="mercure-url">
266+ {{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}
267+ </script>
266268
267269 Then retrieve it from your JS file:
268270
269- .. code :: javascript
271+ .. code-block :: javascript
270272
271273 const url = JSON .parse (document .getElementById (" mercure-url" ).textContent );
272274 const eventSource = new EventSource (url);
You can’t perform that action at this time.
0 commit comments