File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -1555,15 +1555,27 @@ a template helper function:
1555
1555
1556
1556
.. tip ::
1557
1557
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:
1559
1560
1560
- .. code-block :: javascript
1561
-
1562
- < script>
1563
- var route = " {{ path('blog_show', {'slug': 'my-blog-post'})|escape('js') }}" ;
1564
- < / script>
1561
+ .. configuration-block ::
1565
1562
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>
1567
1579
1568
1580
.. index ::
1569
1581
single: Routing; Absolute URLs
You can’t perform that action at this time.
0 commit comments