Skip to content

Commit 8c4725b

Browse files
committed
[#6633] Applied comments
1 parent 606b730 commit 8c4725b

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

book/routing.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,15 +1555,27 @@ a template helper function:
15551555

15561556
.. tip::
15571557

1558-
If you are generating the route inside a script tag, you might need to properly escape it for Javascript
1558+
If you are generating the route inside a ``<script>`` element, it's a good
1559+
practice to escape it for JavaScript:
15591560

1560-
.. code-block:: javascript
1561-
1562-
<script>
1563-
var route = "{{ path('blog_show', {'slug': 'my-blog-post'})|escape('js') }}";
1564-
</script>
1561+
.. configuration-block::
15651562

1566-
For more information, see the Twig documentation.
1563+
.. code-block:: html+twig
1564+
1565+
<script>
1566+
var route = "{{ path('blog_show', {'slug': 'my-blog-post'})|escape('js') }}";
1567+
</script>
1568+
1569+
.. code-block:: html+php
1570+
1571+
<script>
1572+
var route = "<?php echo $view->escape(
1573+
$view['router']->generate('blow_show', array(
1574+
'slug' => 'my-blog-post',
1575+
)),
1576+
'js'
1577+
) ?>";
1578+
</script>
15671579

15681580
.. index::
15691581
single: Routing; Absolute URLs

0 commit comments

Comments
 (0)